[GO LANGUAGE] GO 언어 시작하기2 - Simple is best

in #golanguage6 years ago

Go에 대한 두번째 이야기 - Simple is best


[cmd가 말하는 go]

Go is a tool for managing Go source code.

Usage:

        go command [arguments]

The commands are:

        build       compile packages and dependencies

        clean       remove object files

        doc         show documentation for package or symbol

        env         print Go environment information

        bug         start a bug report

        fix         run go tool fix on packages

        fmt         run gofmt on package sources

        generate    generate Go files by processing source

        get         download and install packages and dependencies

        install     compile and install packages and dependencies

        list        list packages

        run         compile and run Go program

        test        test packages

        tool        run specified go tool

        version     print Go version

        vet         run go tool vet on packages


Use "go help [command]" for more information about a command.

Additional help topics:

        c           calling between Go and C

        buildmode   description of build modes

        filetype    file types

        gopath      GOPATH environment variable

        environment environment variables

        importpath  import path syntax

        packages    description of package lists

        testflag    description of testing flags

        testfunc    description of testing functions

Use "go help [topic]" for more information about that topic.




1) 동시성 프로그래밍

: goroutine 

- 다른 함수 동시 실행 가능 (쓰레드와 비슷한 작동)

- first class(일급 객체)로 정수나 실수와 같은 데이터 타입과 동급 취급

- 만드는 방법: go 뒤에 함수 두면 됨 (ex_ go f(0) -> f(0)함수 실행 goroutine만들어짐)

- goroutine과 main함수는 독립적으로 진행되며,  main함수가 goroutine보다 먼저 종료할 수 있으므로 Scanln함수 이용해 기다리게 하기도 함


: channel : goroutine들 간  데이터 교환 위해 사용 (메시지 교환 통로)

: chan : channel type data 생성 가능

- <- 연산자 이용해 channel에 데이터 read/write 가능

 ex) c<-"pong" 은 channel에 "pong"을 씀

ex) msg := <-c 은 channel에서 읽은 데이터 msg에 저장


2) Interface

; Method들의 모음 

; 그 자체로 하나의 type

; 정의 - Method 형태 / 구현 - 외부 


3) Web programming

; go는 MSA모델 웹 어플리케이션 개발 잘 지원

; 기본으로 지원하는 net/http와 gorilla로 충분히 훌륭한 웹 어플리케이션 서버 개발 가능


4) Unit Test

; 앞선 포스팅에서도 얘기했듯이 분산환경에 최적화 된 go언어는 테스트해야 할 기능이 명확하므로 

더욱더 unit test에서 진가를 발휘한다. 



<Reference>

https://golangkorea.github.io/post/go-start/feature/


Coin Marketplace

STEEM 0.16
TRX 0.13
JST 0.027
BTC 58503.45
ETH 2594.59
USDT 1.00
SBD 2.45