diff --git a/.gitignore b/.gitignore index d957ba8..308d454 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,7 @@ # Go workspace file go.work +# MacOS +.DS_Store + +bin/* \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..99f532e --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug", + "type": "go", + "request": "launch", + "mode": "debug", + "program": "${workspaceRoot}", + "env": {}, + "args": [], + "showLog": true, + }, + { + "name": "Build & Run", + "type": "go", + "request": "launch", + "mode": "exec", + "program": "${workspaceFolder}/bin/hello", + "console": "integratedTerminal", + "preLaunchTask": "go build", + }, + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..f71c78e --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,12 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "go build", + "type": "shell", + "command": "go build -o bin/hello ./...", + "group": "build", + "problemMatcher": ["$go"] + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 9143dbc..5c8d881 100644 --- a/README.md +++ b/README.md @@ -30,15 +30,18 @@ package main import "fmt" func main() { - fmt.Println("Hello World!") - i := 101 - fmt.Println(i) + name := "World" + fmt.Println(getGreeting(name)) +} + +func getGreeting(name string) string { + return fmt.Sprintf("Hello, %s!", name) } ``` Some useful hotkeys: - `Ctrl + Shift + D` - Open Debugger -- `F9` - set or toggle Breakpoint. *Try this line `i := 101`* +- `F9` - set or toggle Breakpoint. *Try this line `name := "World"`* - `F5` - Start Debugging or to Run the Application. If asked to select environment: select `Go` - `F10` - Step Over - `F11` - Step Into @@ -57,14 +60,36 @@ Typical aka untouched `launch.json`: "type": "go", "request": "launch", "mode": "debug", - "remotePath": "", - "port": 2345, - "host": "127.0.0.1", "program": "${workspaceRoot}", "env": {}, "args": [], - "showLog": true + "showLog": true, } ] } -``` \ No newline at end of file +``` + +# Custom build task + +Create `tasks.json`: + +```json +{ + "version": "2.0.0", + "tasks": [ + { + "label": "go build", + "type": "shell", + "command": "go build -o bin/tui ./...", + "group": "build", + "problemMatcher": ["$go"], + } + ] +} +``` + +Add this line to the desired run command in your `launch.json` + +```json +"preLaunchTask": "go build", +```