# 개발 환경 구축

## 개발 환경 구축 (mac)

vs code가 편한것 같다.

### install go

먼저 go를 설치한다.

```sh
brew install go
```

1. <https://go.dev/dl/>
2. download package
3. install package

```sh
go version
```

### visual studio를 설치하고 go plugin을 설치

![](https://3379277180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MaoWGMVdC3ztoOAzHPq%2Fuploads%2Fgit-blob-ac9d2d6ecb8a74b73a5431bb482bd0b0151b1620%2F2022-08-14-11-39-20.png?alt=media)

이걸 설치하자.

<https://marketplace.visualstudio.com/items?itemName=golang.go>

visual studio를 열고 `aaa.go`파일을 만들어보자. 관련된 플러그인을 설치하냐고 물어본다. 설치하자.

또 뭘 설치하냐고 물어오면 전부다 설치한다.

### 추가 작업

참고로 Path가 안맞으면 에러가 날수 있다. .zshrc나 .bash를 수정하자.

```sh
vi ~/.zshrc

export GOPATH=$(go env GOPATH)

export PATH=$(go env GOPATH)/bin:$PATH
```

이렇게 추가해주면 편하게 고를 사용할수 있다.

vs code에서 초반에 gopls관련 워닝이 나기도 한다. 수정하자.

vs code 세팅에서 다음을 추가하자.

```json
"gopls": {
    "experimentalWorkspaceModule": true
  },
"go.toolsManagement.autoUpdate": true,
```

이제 에러가 없어졌다.

## code

`aaa.go` 파일을 다음처럼 작성해보자.

```go
package main

import "fmt"

func main() {
  fmt.Println("Hello, world!")
}
```

빌드하고 실행하자.

```sh
go mod init helloworld
go mod tidy
go build
./helloworld
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://teamsmiley.gitbook.io/devops/go-lang/golang.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
