Skip to content

Commit 4733eb7

Browse files
sample
1 parent 4fb2a59 commit 4733eb7

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

go.md

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -66,39 +66,47 @@ Start remote debugger for current go project. See debugging below.
6666

6767
Install "Go for Visual Studio Code" (ms-vscode.go)
6868

69-
Set tools bin path in VS Code
70-
71-
Code, Preferences, Settings, User settings
72-
... Open settings.json
73-
Set go.toolsGoPath to Tools path
74-
75-
```javascript
76-
{
77-
"git.ignoreMissingGitWarning": true,
78-
"workbench.startupEditor": "newUntitledFile",
79-
"go.toolsGopath": "/Users/bryan/Tools"
80-
}
81-
```
82-
83-
note: I used to point directly to Tools/bin but a recent vscode go plugin wants me to point to Tools and bin is implied.
84-
8569
### Modules
8670

8771
Modules are now released with GO 1.12 and above
8872

8973
[Modules Overview](https://github.com/golang/go/wiki/Modules)
9074

91-
unset $GOPATH. shortcut gomod provided
75+
### HelloWorld in Study
76+
9277
```bash
93-
$ gomod
94-
$ echo $GOPATH
78+
[dev] ~/Projects$ study
79+
[dev] ~/Study$ cd go
80+
[dev] ~/Study/go$ mkdir helloworld && cd helloworld
81+
```
9582

96-
$
83+
Create a module
84+
```bash
85+
[dev] ~/Study/go/helloworld$ go mod init github.com/you/helloworld
86+
go: creating new go.mod: module github.com/you/helloworld
87+
[dev] ~/Study/go/helloworld$ touch main.go
9788
```
9889

99-
For `gr` shortcut, keep the folder name the executable name. For example, in the modules walkthrough above, I named package hellomod in the hellomod folder (instead of hello in the mod folder). A good convention.
90+
edit main.go
91+
```
92+
package main
93+
94+
import (
95+
"fmt"
96+
)
97+
98+
func main() {
99+
fmt.Println("Hello World!")
100+
}
101+
```
100102

101-
Notice this commit added tools gocode-mod and godef-mod
103+
build and run
104+
```bash
105+
[dev] ~/Study/go/helloworld$ gr
106+
building /Users/bryan/Study/go/bin/helloworld
107+
running /Users/bryan/Study/go/bin/helloworld
108+
Hello World!
109+
```
102110

103111
### Debug
104112

0 commit comments

Comments
 (0)