상세 컨텐츠

본문 제목

VScode (visual studio code) Go 설정

Programming/Go

by 크리두 2020. 6. 7. 13:39

본문

반응형

code.visualstudio.com

 

Visual Studio Code - Code Editing. Redefined

Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications.  Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows.

code.visualstudio.com

 

최근에 거의 모든 플랫폼을 지원해주는 vscode가 대세인거 같네요.

그런데다가 이런 에디터를 무료로 지원을 해주다니...

설치는 아주 간단하게 OS버전에 맞게 다운로드 후 설치합니다.

 

빌 게이츠 형님 Flex

 

 

Typescript 기반이라고 하는데 저도 순수 개발자가 아니다 보니

어떤게 좋은지는 차차 공부해보면서 사용하고 정리해봐야겠네요.

 

이번에는 Go Lang. 공부를 하려고 설정을 어떻게 해야하나 정리해보려고 합니다.

 

일단 공식 사이트 가서 다운로드 받아서 설치하시면 됩니다.

 

각 플랫폼에 맞게 다운로드하고 설치하시면 됩니다.

딱히 요즘은 환경변수도 잘 맞춰주고 굉장히 편하게 되어있어서 금방 설치할 수 있습니다.

 

각종 언어를 지원해주는 확장 플러그인도 설치하면 굉장히 편하다는 걸 알수 있습니다.

Pallete에서 Extensions: Install Extensions를 선택해서 go를 검색하시면 플러그인 설치가 가능합니다.

 

이렇게 하시면 설정이 거의 완료가 되어 바로 사용 가능합니다.

그런데 저는 갑자기 auto import 기능이 갑자기 설정이 안되더라구요.

 

아래 링크 타고 가셔서 참조하시면 각 언어의 설정 방법이 정리되어 있습니다.

 

자동 완성 기능에 대한 설명입니다.

vscode는 settings.json에서 각종 설정을 관리하는 형태로 되어 있습니다.

아래 설명은 읽어 보시면 되고 간단히 정리하면 sttings.json에다가 아래 내용을 추가하시면 될겁니다.

"go.autocompleteUnimportedPackages": true

Auto completions

As you type in a Go file, you can see IntelliSense providing you with suggested completions. This even works for members in current, imported, and not yet imported packages. Just type any package name followed by ., and you will get suggestions for the corresponding package members.

By setting go.autocompleteUnimportedPackages to true in your settings, you can also get suggestion for packages that you could import. Select one of these suggestions and an import to the selected package will be added to your file.

 

code.visualstudio.com/docs/languages/go

 

Go with Visual Studio Code

Learn about Visual Studio Code editor features (code completion, debugging, snippets, linting) for Go.

code.visualstudio.com

설정이 제대로 된다면 간다히 코드 작성을 하면서 자동 완성 기능이 되는지 확인해봅시다.

 

package main

import (
	"fmt"
)

func main()  {
	fmt.Println("hello world")
}

 

역시 hello world를 해봐야겠죠 ㅎㅎㅎ

 main function에서 fmt를 타이핑 후 탭을 누르시면 위에 import가 자동으로 완성되면

설정이 잘 되었다는 것을 확인할 수 있습니다.

 

그럼 이제 설정이 완료되었으니 Go를 이용해서 웹 스크래핑 프로그램을 만들어 봐야겠습니다.

 

반응형

댓글 영역