My app is packaged as the following:
|-cmd/
|-cmd/application/ <- this contains the main.go and other files
|-internal/ <- contains internal dependencies
|-vendor/ <- contains third party libraries
And when running the following command from the root /
:
go build cmd/application/*.go
It produces an executable that works fine. But when typing the following command from inside /cmd/application
:
go build my_app_custom_name
I get the Syntax error: newline unexpected
error, as if it wasn't a bash executable anymore.
With the help of the indication @Volker after using the flags -v and -x I figured out that I was naming the package "myapp" and not "main" as it should be. Now it works just fine.
As said by @Kaedys and @JimB, it is preferable to use the standard form for building apps :
go build // Method one from inside directory with go files
go build full/import/path/of/package/to/build // second method
Note that this is the recommended way in How to write Go code
The other way to build is using go build .
and go build *.go
in the directory where you go package is.