Go

[Go] VSCode에서 Golang 실행

happyso 2024. 2. 7. 18:09

https://learn.microsoft.com/ko-kr/azure/developer/go/configure-visual-studio-code

 

Go 개발을 위한 Visual Studio Code 구성 - Go on Azure

이 문서는 Go용 Visual Studio Code 개발을 구성하는 데 도움이 됩니다.

learn.microsoft.com

 

1. Go Extention Install

2. Ctrl + Shifp + p 로 VSCode 명령팔레트에 go tool 검색

3. Go 도구 모두 선택 후 확인

4. Go 도구 업데이트 완료

5. Run and Debug 버튼 아래의 create a launch.json file 클릭

6. 본인의 프로젝트에 맞게 launch.json 구성

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch Package",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            // 현재 실행 폴더 경로
            "cwd": "/home/snchoi/project/src/golangproject/",
            // main.go가 존재하는 폴더 경로
            "program": "/home/snchoi/project/src/golangproject/cmd/",
            // program arguments
            "args": [
              "--listen=3000",
              "--log-level=debug"
            ]
        }
    ]
}

7. 실행

  • Ctrl + F5 - 디버깅 없이 실행
  • F5 - 디버깅 및 실행

8. 디버거 실행

break point를 잡고 F5로 디버깅 실행을 하면 좌측에서 디버깅에 대한 정보를 확인할 수 있다.

 

https://github.com/golang/vscode-go/wiki/features

 

features

Go extension for Visual Studio Code. Contribute to golang/vscode-go development by creating an account on GitHub.

github.com

VSCode로 Go를 실행할 경우 생각보다 많은 기능들을 제공해준다 ㄷ ㄷ