Skip to content

Commit

Permalink
Add install instructions and small mad lib program
Browse files Browse the repository at this point in the history
  • Loading branch information
jmw511 committed Aug 31, 2015
1 parent 05f76da commit 9470047
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
73 changes: 73 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
You can download the Go tools package installer or the archive from: https://golang.org/dl/

If you download the archive:

Extract into /usr/local

Add Go PATH to your system profile:

export PATH=$PATH:/usr/local/go/bin

If you want to install the Go tools into a different location you can set a GOROOT env variable to point to that directory

Add GOROOT to your .bash_profile or .profile:

export GOROOT=$HOME/go
export PATH=$PATH:$GOROOT/bin

If you download the package installer:

Open the installer and install the tools.

Mac OS X:

The installer will install go to /usr/local/go and will put the directory (/usr/local/go/bin) into your PATH env variable.

Test that you've installed Go correctly and run your first "Hello, Word." program:

Create a new directory and set up a workspace:

Set a GOPATH env variable in your .bash_profile or .profile:

$ export GOPATH=$HOME/workspace

Create your first Go program:

Make the directories src/github.com/(your github username)/hello inside your workspace directory.
While inside the hello directory create a file named hello.go and add:

package main

import "fmt"

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

Compile your first Go program:

$ go install github.com/(your github username)/hello

Run your first Go program:

After compiling the program an executable will be inside the bin directory of the workspace:
$HOME/workspace/github.com/(your github username)/bin or $GOPATH/bin

To run the program run:

$ $GOPATH/bin/hello















21 changes: 21 additions & 0 deletions madlib.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package main

import "fmt"

func main() {
fmt.Println("Mad lib program!")
fmt.Println("Give me a noun!: ")
var noun string
var verb string
var adjective string
var noun2 string
fmt.Scanln(&noun)
fmt.Println("Give me a verb!: ")
fmt.Scanln(&verb)
fmt.Println("Give me an adjective!: ")
fmt.Scanln(&adjective)
fmt.Println("Give me another noun!: ")
fmt.Scanln(&noun2)

fmt.Println(fmt.Sprintf("The %v %v to the %v %v", noun, verb, adjective, noun2))
}

0 comments on commit 9470047

Please sign in to comment.