Golang
-
Golang Gin API Swagger 붙이기Golang 2022. 12. 16. 05:06
https://github.com/swaggo/swag#api-operation GitHub - swaggo/swag: Automatically generate RESTful API documentation with Swagger 2.0 for Go. Automatically generate RESTful API documentation with Swagger 2.0 for Go. - GitHub - swaggo/swag: Automatically generate RESTful API documentation with Swagger 2.0 for Go. github.com 계기 보통 GraphQL을 기본 api로 사용하고 있기 때문에 swagger에 필요성을 느끼지 못하고 있었는데 최근 다른 외부 서비스..
-
Golang에서 SMTP 로 mail 보내기 (gmail)Golang 2022. 9. 4. 18:24
App 사용을 위한 계정 생성하기 기존에는 google 로그인 시 사용하던 id / pwd로 mail을 보낼 수 있었지만 보안 정책이 변경되어 app 계정을 따로 생성해야 한다. 이제 smtp 계정을 설정할 때 내 mail주소와 화면에 나온 app 비밀번호를 사용하면 된다. code 작성 package gomail import ( "bytes" "encoding/json" "errors" "fmt" "html/template" "io/ioutil" "log" "net/smtp" "os" "path/filepath" ) func SendEmailSMTP(to []string, data interface{}, template string) (bool, error) { type credential struct..
-
Golang Server Base Code (graphQL, restAPI, mongoDB, postgresql)Golang 2022. 4. 22. 21:33
https://github.com/zzihyeon/golang-server GitHub - zzihyeon/golang-server: graphQL, restAPI, postgresql, mongoDB graphQL, restAPI, postgresql, mongoDB. Contribute to zzihyeon/golang-server development by creating an account on GitHub. github.com Golang 개발을 하고싶은데 처음 환경 setting이 어려운 사람들을 위해서 graphQL, restAPI, mongoDB, postgresql 관련 기본 setting을 한 base code를 push하였다.
-
Golang GraphQL 서버 #5 (타입 리졸버 추가하기)Golang 2022. 3. 22. 12:28
https://zzihyeon.tistory.com/43 Golang GraphQL 서버 #4 (커스텀 타입 매핑하기) https://zzihyeon.tistory.com/15 Golang GraphQL 서버 #3 zzihyeon.tistory.com/14 Golang graphQL Playground 사용법 zzihyeon.tistory.com/13 Golang GraphQL 서버 setting (gqlgen 사용) workspace directory.. zzihyeon.tistory.com 추가적으로 도움이 되는 기능 1. Type에 리졸버 추가하기 아래의 User struct에 대해서 school에 대한 Resolver를 추가하고 싶다면 어떻게 해야할까? type User { uid: Int64! ..
-
Golang GraphQL 서버 #4 (커스텀 타입 매핑하기)Golang 2022. 3. 22. 12:12
https://zzihyeon.tistory.com/15 Golang GraphQL 서버 #3 zzihyeon.tistory.com/14 Golang graphQL Playground 사용법 zzihyeon.tistory.com/13 Golang GraphQL 서버 setting (gqlgen 사용) workspace directory를 생성한다. mkdir DevBasic go mod 설정을 한다. go mod i.. zzihyeon.tistory.com 추가적으로 도움이 되는 기능 1. 커스텀 타입 매핑하기 (99designs/gqlgen: go generate based graphql server library (github.com)) 개발을 하다보면 Type을 int64, int32, int를 구..
-
Golang Postgresql SQLC 설정하기Golang 2022. 3. 21. 23:32
계기 SQL 문만 작성하면 자동으로 타입을 선언하고 메서드를 생성해주는 좋은 툴이 있어서 사용하게 되었다. 적용 단점: Postgresql sqlc 는 window에서 지원하지 않는다. 그래서 본인은 wsl(window subsystem for linux)를 사용하다가 너무 문제가 많아서 그냥 이 김에 맥북을 하나 장만했다. sqlc: kyleconroy/sqlc: Generate type-safe code from SQL (github.com) GitHub - kyleconroy/sqlc: Generate type-safe code from SQL Generate type-safe code from SQL. Contribute to kyleconroy/sqlc development by creating..
-
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)