launch.json and build tasks.json
This commit is contained in:
		
							parent
							
								
									b77b452658
								
							
						
					
					
						commit
						5799ca4872
					
				
							
								
								
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -37,3 +37,7 @@
 | 
				
			|||||||
# Go workspace file
 | 
					# Go workspace file
 | 
				
			||||||
go.work
 | 
					go.work
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# MacOS
 | 
				
			||||||
 | 
					.DS_Store
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bin/*
 | 
				
			||||||
							
								
								
									
										24
									
								
								.vscode/launch.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								.vscode/launch.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -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",
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					    ]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										12
									
								
								.vscode/tasks.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								.vscode/tasks.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					  "version": "2.0.0",
 | 
				
			||||||
 | 
					  "tasks": [
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      "label": "go build",
 | 
				
			||||||
 | 
					      "type": "shell",
 | 
				
			||||||
 | 
					      "command": "go build -o bin/hello ./...", 
 | 
				
			||||||
 | 
					      "group": "build",
 | 
				
			||||||
 | 
					      "problemMatcher": ["$go"]
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  ]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										41
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								README.md
									
									
									
									
									
								
							@ -30,15 +30,18 @@ package main
 | 
				
			|||||||
import "fmt"
 | 
					import "fmt"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func main() {
 | 
					func main() {
 | 
				
			||||||
    fmt.Println("Hello World!")
 | 
						name := "World"
 | 
				
			||||||
    i := 101
 | 
						fmt.Println(getGreeting(name))
 | 
				
			||||||
    fmt.Println(i)
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func getGreeting(name string) string {
 | 
				
			||||||
 | 
						return fmt.Sprintf("Hello, %s!", name)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Some useful hotkeys:
 | 
					Some useful hotkeys:
 | 
				
			||||||
- `Ctrl + Shift + D` - Open Debugger
 | 
					- `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`
 | 
					- `F5` - Start Debugging or to Run the Application. If asked to select environment: select `Go`
 | 
				
			||||||
- `F10` -  Step Over
 | 
					- `F10` -  Step Over
 | 
				
			||||||
- `F11` - Step Into
 | 
					- `F11` - Step Into
 | 
				
			||||||
@ -57,14 +60,36 @@ Typical aka untouched `launch.json`:
 | 
				
			|||||||
            "type": "go",
 | 
					            "type": "go",
 | 
				
			||||||
            "request": "launch",
 | 
					            "request": "launch",
 | 
				
			||||||
            "mode": "debug",
 | 
					            "mode": "debug",
 | 
				
			||||||
            "remotePath": "",
 | 
					 | 
				
			||||||
            "port": 2345,
 | 
					 | 
				
			||||||
            "host": "127.0.0.1",
 | 
					 | 
				
			||||||
            "program": "${workspaceRoot}",
 | 
					            "program": "${workspaceRoot}",
 | 
				
			||||||
            "env": {},
 | 
					            "env": {},
 | 
				
			||||||
            "args": [],
 | 
					            "args": [],
 | 
				
			||||||
            "showLog": true
 | 
					            "showLog": true,
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# 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",
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user