Golang
-
golang postgresql migrate 설정하기Golang 2022. 3. 21. 22:56
계기 개발 초기에 DB schema 변경이 잦고 이에 따라 Table을 drop 하고 create할 일이 많은데 이를 편하게 하기 위해 적용하게 되었다. 적용 우선 정상적으로 동작하는 postgresql DB 서버가 필요하다. 이는 그냥 docker로 간단하게 켜서 확인하면 된다. migrate CLI: migrate/cmd/migrate at master · golang-migrate/migrate (github.com) GitHub - golang-migrate/migrate: Database migrations. CLI and Golang library. Database migrations. CLI and Golang library. Contribute to golang-migrate/migrate..
-
golang 에러 Fatal error: newproc: function arguments too large for new goroutineGolang 2021. 11. 14. 22:24
이 에러는 goroutine 사용 시 인자로 넘겨주는 argument값이 너무 커서 발생하는 에러이다. 값을 넘기는 대신 값의 주소값을 넘기면 해결할 수 있다. 예를들어 a := []string{"1","1",1","1"......} //아주 큰 배열 go func(a []string){ fmt.Println(a) }(a) 와 같은 식으로 사용하면 위 에러가 발생 할 것이다. 이를 해결하기 위해서는 아래와 같이 go func의 args를 주소값을 넘기도록 변경하면 된다. a := []string{"1","1",1","1"......} //아주 큰 배열 go func(a *[]string){ //주소값으로 변경 fmt.Println(a) }(&a)
-
Golang GraphQL 서버 #3 (Resolver)Golang 2021. 5. 1. 23:21
zzihyeon.tistory.com/14 Golang graphQL Playground 사용법 zzihyeon.tistory.com/13 Golang GraphQL 서버 setting (gqlgen 사용) workspace directory를 생성한다. mkdir DevBasic go mod 설정을 한다. go mod init devbaisc gqlgen을 install한다. go get github.com/99de.. zzihyeon.tistory.com 에서 설정한 playground에서 query를 실행하면 아래와 같이 internal system error가 발생한다. 이는 resolver 함수를 작성하지 않았기 때문이다. 아래의 CreateTodo와 Todos Resolver가 모두 error..
-
Golang GraphQL 서버 #2 (playground)Golang 2021. 4. 27. 22:21
zzihyeon.tistory.com/13 Golang GraphQL 서버 setting (gqlgen 사용) workspace directory를 생성한다. mkdir DevBasic go mod 설정을 한다. go mod init devbaisc gqlgen을 install한다. go get github.com/99designs/gqlgen gqlgen을 셋팅한다 go run github.com/99designs/gqlgen.. zzihyeon.tistory.com 를 따라 서버를 만들었다면, 실행 시 아래와 같은 로그가 뜬다. 이제 위의 url http://localhost:8080/playground를 통해 playground로 접속해 보자 위와 같이 playground가 연결된 것을 확인할 수 ..