I am an idiot. Its only through mistakes that you learn tho. I have recently been running into issues with my new golang projects. ONLY the new ones. whenever I try to make a new project, it would always have issues. THe biggest issue is the fact that the go build command wuold not produce an executable without -o main.exe. When an executable was produced, if I ran it I got
$ ./main.exe
./main.exe: line 1: syntax error near unexpected token newline' ./main.exe: line 1: !'
I thought that this was something wrong with my install. Possibly my environmental varaibles. Digging through those proved not to help. I poked arround the go irc, (far and away the best place to go for help), and finally someone was able to catch what I was doing wrong.
It had been so long since I last created a project, and I had only ever created one mod project from scratch, that I was confusing the errors that I got, and I kept trying to compile the following to an executable.
package lab5
import "fmt"
func main(){
fmt.Println("Hello World")
}
The issue at hand is the package name. go build only produces an executable for main packages. IE "package main" with a func main().
package main
import "fmt"
func main(){
fmt.Println("Hello World")
}
Not a mistake I will make again I think.
Thank you!