Go Package
Suppose we want to create a simple Go project that prints “Hello world” and prints the list of the arguments passed.
Let’s create the project:
go mod init github.com/my-cliNow, let’s create our main.go:
touch main.goAnd add the content:
package main
import ( "fmt" "os")
func main() { fmt.Println("Hello, World!")
fmt.Println("\n--------Args-------") for _, arg := range os.Args { fmt.Println("- " + arg) } fmt.Println("----end of args----\n")}If we run this program with Go:
go run . --flag --another flagWe’ll have something like this:
Hello, World!
--------Args-------- /var/folders/xp/ctz4hzmj66d5sz29pgpvlnjm0000gn/T/go-build715925125/b001/exe/my-cli- --flag- --another- flag----end of args----Cool. Now, let’s release this for all platforms.