Go 언어 유닛테스트 대하여 배워보기
오늘은 Go 언어에서 유닛테스트를 해보는 방법을 작성하면서 배워보려 합니다. package main import ( "fmt" ) func main() { fmt.Println(CalcUnitTest(5,10,15)) } // CalcUnitTest function func CalcUnitTest(n ...int)int{ i := 0 f...
오늘은 Go 언어에서 유닛테스트를 해보는 방법을 작성하면서 배워보려 합니다. package main import ( "fmt" ) func main() { fmt.Println(CalcUnitTest(5,10,15)) } // CalcUnitTest function func CalcUnitTest(n ...int)int{ i := 0 f...
오늘은 Go 언어에서 간단하게 로그를 남겨보는 법을 작성하면서 배워보려 합니다. package main import ( "log" "os" ) func test() { log.Print("Test") } func main() { test() } 기본적으로 날짜와 시간이 같이 로그로 출력됩니다. package m...
오늘은 Go 언어에서 간단하게 서버를 만들어 보는 내용을 작성하면서 배워보려 합니다. package main import ( "net/http" ) func hello(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Hello World")) } func main() { http.H...
오늘은 Go 언어의 xml 읽고 쓰기에 대하여 작성하면서 배워보려 합니다. package main import ( "encoding/xml" "fmt" ) type test struct { Title string Text string Index int } func main() { t :=...
오늘은 Go 언어의 json 읽고 쓰기에 대하여 작성하면서 배워보려 합니다. package main import ( "encoding/json" "fmt" ) // test struct type test struct { Title string Text string Index int } fu...
오늘은 Go 언어의 http get에 대하여 작성하면서 배워보려 합니다. package main import ( "fmt" "io/ioutil" "net/http" ) func main() { page, _ := http.Get("http://info.cern.ch/") data, _ := ioutil.Re...
오늘은 Go 언어의 파일 입출력에 대하여 작성하면서 배워보려 합니다. package main import ( "fmt" "os" ) func main() { data, _ := os.Create("test.txt") fmt.Fprintln(data,"파일에 쓰고 있습니다.") fmt.Fprintln(data,"Fprintln() 함수는 ...
오늘은 Go 언어의 mutex에 대하여 작성하면서 배워보려 합니다. package main import ( "time" "fmt" "sync" ) 우선 메인 함수가 끝나는 시간을 지연시키기 위한 time과 출력을 하기 위한 fmt, 그리고 mutex를 사용하기 위한 sync를 가져옵니다. func main() { var m s...
오늘은 Go 언어의 select에 대하여 작성하면서 배워보려 합니다. package main import ( "time" "fmt" ) func function(c chan int) { time.Sleep(1) c <- 21 } func main() { c :=make(chan int) go function(c) for { ...
오늘은 Go 언어의 채널에 대하여 작성하면서 배워보려 합니다. package main import ( "fmt" ) func main() { var a chan int fmt.Println(a) a = make(chan int) fmt.Println(a) } int 채널을 선언하기만 하면 nil으로 표기되고, make로 초기화하면 주...