Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Last active October 26, 2023 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilmoore/6121941 to your computer and use it in GitHub Desktop.
Save wilmoore/6121941 to your computer and use it in GitHub Desktop.
Software Engineering :: Programming :: Languages :: GoLang :: Your First Go Program

Create a project directory

⪼ Made with 💜 by realpolyglot.com

About

SEE: http://golang.org/doc/code.html

% mkdir -p /tmp/starter
% cd !$

Create the source directory

% mkdir src

Create a package

% mkdir -p src/$USER/hello

Add source file (src/$USER/hello/hello.go)

% cat > src/$USER/hello/hello.go <<EOF
package main

import "fmt"

func main() {
  fmt.Printf("Hello, world.\n")
}
EOF

Compile

% GOPATH=$PWD go install $USER/hello

Run binary

% ./bin/hello
#=> Hello, world.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment