Let's write a few variations of our first program.
The first statement in a Go source file must be package name. Executable commands must always use package main. -- https://go.dev/doc/code
A package main
and a file using a different package name cannot live in the
same directory.
- example: x/twopkgs
$ make
found packages main (main.go) and other (other.go) in /home/tir/code/miku/gows/x/twopkgs
This is why you see a projects with entry points separating commands into a
subdirectory, like cmd
(which itself can be traced to
plan9).
Not required for one-off tools, e.g.:
For a first tool, this minimalistic approach is quite nice.
Go code is expected to be encoded in UTF-8.
Source code in Go is defined to be UTF-8 text; no other representation is allowed. [...] To summarize, strings can contain arbitrary bytes, but when constructed from string literals, those bytes are (almost always) UTF-8. -- https://go.dev/blog/strings