Can't even do regex without some shit about pointers

Can't even do regex without some shit about pointers

Attached: 57bb2a1f-golang.png (752x471, 146.23K)

>made by google
you just know

>scared of pointers
As expected of neo-Any Forums.

nobody has been able to fix it.
Its a simple as it gets script too
package main

import (
"fmt"
"log"
"os"
"path/filepath"
"regexp"
)

func printFile(path string, info os.FileInfo, err error) error {
if err != nil {
log.Print(err)
return nil
}
fmt.Println(path)
return nil
}
func step2(dir string) string {
err := filepath.Walk(dir, printFile)//get the subdirectories and files in a directory
if err != nil {
log.Fatal(err)
}
re := regexp.MustCompile(`[^\\]*\\`)
re2 := re.ReplaceAllString(err.Error(), " ")
re3 := regexp.MustCompile("$")
re4 := re3.ReplaceAllString(re2, "
")

return re4
}
func main() {
log.SetFlags(log.Lshortfile)
dir := "."
step2(dir)
}

user, err is always nill by the time you reach
>re2 := re.ReplaceAllString(err.Error(), " ")
so calling
>err.error()
will crash, wont it ?

wont even run this code, looks like shit btw

wtf are you trying to do?

Get the currect directory and replace a few characters

>if err != nil { log.Fatal(err) }
>err.Error()
Can't you even? Why are you trying to get the error message after you just handled the error if it did exist?

it doesnt matter
The error nils dont matter
Itll say that it has deference nil pointer
This thing wants a raw pointer and i dont know what exactly it wants
needless to say i wont be using go for what im doing anyways
javas regex is also not that straight foward but im assuming itd work
maybe i should just use boring ol nodejs

why even use regex for that?
package main

import (
"fmt"
"os"
"path/filepath"
"strings"
)

func step(path string, info os.FileInfo, err error) error {
path = strings.ReplaceAll(path, string(os.PathSeparator), "&emps;")
path += "
"
fmt.Println(path)
return nil
}

func main() {
filepath.Walk(".", step)
}

OP, have you ever been told you are a fucking retard that should stop trying so hard to understand shit you aren't even good at?
because whatever you are trying to do, you are doing it wrong, you absolute retard.

Yeah, you are dereferencing err when you call "err.Error()", but err can only be nil since you handle the case of it not being nil when you do "if err != nil { log.Fatal(err) }"
>maybe i should just use boring ol nodejs
No, you learn this. Don't give up, otherwise you will never become better.

Please don't beg for programming help with sensationalism.

filepath.Walk takes a function that receives whatever files are found in the directory you give. You are checking if there was an error, and if there was log.Fatal exits the program. Why are you trying to do regex operations on a nil error after that?

Oh...
os.PathSeparator...
I mean still it doesn't delete what went prior to the separator though but it'll do. Thanks
Still kind of sucks it can't do regex in this case

I tried writing into an html file with code and it gave me the same error. This thing is just broken.

Yes it can do regex. You do not understand what you are doing.

>too easy regex

Attached: FFFLAT.png (752x471, 160.11K)

>language made specifically for novices who aren't very good programmers
>royally cock it up in the most retarded way
>fail to understand extremely obvious implications of what you're writing
I don't usually lose my faith in humanity this early in the morning.

Read the documentation on the functions you are using. Understand what filepath.Walk returns: an error. This is an interface type, which is nillable. You either get an error, or nil. And you handled the non-nil case with an early os.Exit() hidden inside log.Fatal, so err can only be nil after that if block because otherwise the program is over.

Regexp takes a string. You are passing it nil. You don't even want to do a regex on whatever error that function returns. You want to do the regex on the file paths that are found by that function and passed to your printFile function. At no point in the body of step2 is there anything resembling usable data in the success path. All the usable data in the success path exists inside the scope of printFile.

made me chuckle, 10/10

never mind, I solved it
const fs=require("fs")
const dree = require('dree');
const tree = dree.parse('.')
const r=tree.split('\n').join('')
console.log(r)
fs.writeFileSync("test1.html",r)

Attached: R (6).jpg (876x799, 81.4K)

>script
>Go

Attached: 1658424386481.jpg (310x310, 26.6K)