Skip to content

Instantly share code, notes, and snippets.

@bushidocodes
Created April 26, 2017 23:29
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 bushidocodes/85dcd9991eae9bea0faf96076610da94 to your computer and use it in GitHub Desktop.
Save bushidocodes/85dcd9991eae9bea0faf96076610da94 to your computer and use it in GitHub Desktop.
Is my Go setup properly?

This script will test that go is installed and the GOPATH is properly set

package main

import (
	"log"
	"os"
	"path/filepath"
	"strings"
)

func main() {
	gopath := os.Getenv("GOPATH")
	if gopath == "" {
		log.Fatal("Your GOPATH has not been set!")
	}

	path := os.Getenv("PATH")
	gobin := filepath.Join(gopath, "bin")
	if !strings.Contains(path, gobin) {
		log.Fatalf("Your PATH does not contain %s", gobin)
	}
	log.Println("Success!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment