본문 바로가기

GO lang/web

(11)
[GO] Web - Restful API, TDD 패키지 설치 위치 - 본인의 프로젝트 폴더에서 실행. 패키지 설치 방법 1. go get -u github.com/gorilla/mux D:\workspace\GO\tuckersGo\goWeb\web05>go get -u github.com/gorilla/mux go: downloading github.com/gorilla/mux v1.8.0 go get: added github.com/gorilla/mux v1.8.0 환경 설정은 아래와 같이 설정함. PS D:\workspace\GO\tuckersGo\goWeb> cd .\web05\ PS D:\workspace\GO\tuckersGo\goWeb\web05> go mod init GO/tuckersGo/goWeb/web05 go: creating ne..
[GO] Web - 테스트 코드 작성방법(TDD) 기존에 작업한 "Web - Text, json, URL 쿼리 방식" 코드에 대한 테스트 코드입니다. 테스트 코드를 작성하기 전에 2개의 패키지를 설치해야 함. 설치 위치 - 본인의 프로젝트 폴더에서 실행. 설치방법 1. go get github.com/smartystreets/goconvey 2. 환경변수 path에 추가 ===> "%GOPATH%\bin" 3. go get github.com/stretchr/testify/assert ./myapp/app_test.go - 5가지의 테스트 경우를 점검함. package myapp import ( "encoding/json" "github.com/stretchr/testify/assert" "io/ioutil" "net/http" "net/http/htt..
[GO] Web - Text, json, URL 쿼리 방식 간단한 golang 으로 만든 웹페이지 입니다. 프로젝트 폴더위치 및 패키지 위치에 따른 오류는 본인의 환경에 맞게 수정이 필요함. ./main.go package main import ( "GO/tuckersGo/goWeb/web04/myapp" // 개인 패키지 위치이므로 본인에 맞게 수정할것 "net/http" ) const portNumber = ":3000" func main() { mux := myapp.NewHttpHandler() http.ListenAndServe(portNumber, mux) } ./myapp/app.go package myapp import ( "encoding/json" "fmt" "net/http" "time" ) type User struct { FirstName..