From 21fc7f113d6f4052826b6ea9f5ea74e6282bd325 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 20 Sep 2018 14:06:57 -0600 Subject: [PATCH] add concise, follow-along examples for the uninitiated (what I wish I had had) --- Modules.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Modules.md b/Modules.md index 367be4d0..e967e847 100644 --- a/Modules.md +++ b/Modules.md @@ -55,6 +55,27 @@ Once installed, you can then activate module support in one of two ways: * Invoke the `go` command in a directory outside of the `$GOPATH/src` tree, with a valid `go.mod` file in the current directory or any parent of it and the environment variable `GO111MODULE` unset (or explicitly set to `auto`). * Invoke the `go` command with `GO111MODULE=on` in the command environment. +For example: + +Assume that `GOPATH=~/go`, your project is called `go-pheonix`, you use github as `gopher111`, and that you already keep other code is in `~/code` + +``` +mv ~/go/github.com/gopher111/go-pheonix ~/code/go-pheonix +cd ~/code/go-pheonix +git init || echo "module github.com/gopher111/go-pheonix" >> go.mod +go get "github.com/spacely/go-sprocket" +go build ./... +``` + +Alternatively + +``` +cd ~/go/github.com/gopher111/go-pheonix +git init || echo "module github.com/gopher111/go-pheonix" >> go.mod +GO111MODULE=on go get "github.com/spacely/go-sprocket" +GO111MODULE=on go build ./... +``` + ## New Concepts These sections provide a high-level introduction to the main new concepts. For more details and rationale, please see [the official proposal document](https://golang.org/design/24301-versioned-go), this 40-minute introductory [video by Russ Cox describing the philosophy behind the design](https://www.youtube.com/watch?v=F8nrpe0XWRg&list=PLq2Nv-Sh8EbbIjQgDzapOFeVfv5bGOoPE&index=3&t=0s), or the more detailed initial [vgo blog series](https://research.swtch.com/vgo).