I’m working on my first Go generate package that creates a Go file similar to the
stringer tool’s (type)_string.go file. I’m still in the tinkering phase, so I’m not sure what the default file name should be. I decided to create a constant,
pkgsyms_go = "pkgsyms.go" and reference the constant in the few places I need it so that if I change it, I get compiler errors until I fix all the names to make it consistent.
When VS Code lints my code, I get this warning:
don't use underscores in Go names; const pkgsyms_go should be pkgsymsGo
I know what this warning means and I’m not going to fight with the linter; I’ll just rename it to pkgsymsGo. What I’m wondering is the explanation behind this warning. If nobody knows what the reason is, does anyone know how I could find it out myself?
I’ve searched through the language specification and saw that you can use underscores between digits to make numbers easier to read, but I don’t know if that’s why they’re discouraged from use in identifiers or not. I have also tried Googling for the reason, but I’m only finding explanations of what the single underscore ("
_ ") is for.
Does anyone know why using underscores in identifiers is a warning from the linter?
P.S.: I don’t actually know what linter I’m running or actually how to find out what it is… I usually just write my code in a plain text editor and go through the compiler’s warnings/errors line by line until I get it working. I’ve used VS Code before and I like the more frequent error and warning message updates, but I don’t know how to find out what magic is producing them!