728x90 반응형 SMALL IT 인터넷/Golang17 Go 언어를 ChatGPT에게 배우다 :: Golang [ 설치 ] MacOS에서 Go (Golang)을 설치하는 방법은 다음과 같습니다. Go의 최신 버전을 다운로드합니다: https://golang.org/dl/ 다운로드한 파일을 압축 해제합니다. 압축 해제한 폴더를 /usr/local/go 로 이동시킵니다. 터미널에서 간단한 설정을 합니다. 환경 변수 $GOPATH를 설정합니다. (ex: export GOPATH=$HOME/go) $PATH에 /usr/local/go/bin을 추가합니다. (ex: export PATH=$PATH:/usr/local/go/bin) 터미널에서 "go version"을 입력하여 설치가 잘 되었는지 확인합니다. 축하합니다! MacOS에서 Go (Golang)이 설치되었습니다. [ 변수 ] Go (Golang)에서 변수 선언 및.. 2023. 2. 5. [Copper] 프로젝트 생성하기 터미널에서 실행. $ copper create coppertest $ cd coppertest $ copper run -watch copper create 할 때 -frontend 와 -storage 를 사용할 수 있어요. -frontend Go Templates (default) Tailwind React React + Tailwind REST API (no frontend) -storage sqlite3 (default) postgres mysql none 영어, 중국어 공부중이신가요? 홈스쿨 교재. 한 권으로 가족 모두 할 수 있어요! 한GLO 미네르바에듀 : 네이버쇼핑 스마트스토어 한글로 영어가 된다?! 한글로[한GLO]는 영어 중국어 일어 러시아어 스페인어가 됩니다!! smartstore.nav.. 2022. 9. 15. [Copper] 설치 CLI $ go install github.com/gocopper/cli/cmd/copper@latest 잘 설치되었는지 확인해요. $ copper -h 위 코드가 작동하지 않으면 ~/.zshrc 또는 ~/.bashrc에 아래 코드를 넣으세요. export PATH=$HOME/go/bin:$PATH 터미널을 재실행한 후 다시 해보세요. 영어, 중국어 공부중이신가요? 홈스쿨 교재. 한 권으로 가족 모두 할 수 있어요! 한GLO 미네르바에듀 : 네이버쇼핑 스마트스토어 한글로 영어가 된다?! 한글로[한GLO]는 영어 중국어 일어 러시아어 스페인어가 됩니다!! smartstore.naver.com 2022. 9. 15. [Copper] 카퍼 소개 https://gocopper.dev/ Copper - Toolkit to build web apps in Go. Fast. 🔩 First-party packages Includes packages for authentication, pub/sub, queues, emails, and websockets. gocopper.dev Copper는 웹 앱을 구축하는 데 필요한 모든 것을 갖춘 Go 툴킷입니다. 개발자 생산성에 중점을 두고, 더 적은 상용구로 Go에서 웹 앱을 더 재미있게 구축하고, 일반적인 요구 사항에 대해 즉시 사용 가능한 지원을 제공합니다. 가장 중요한 것은 여러분의 방해가 되지 않고 Go 표준 라이브러리에 최대한 의존하여 코드를 관용적인 Go로 유지한다는 것입니다. 풀스택 툴킷 🚀 Cop.. 2022. 9. 15. [Golang] Gin + gqlgen [GraphQL] 새로운 폴더 만들고 시작할께요. 1. 설치 $ go mod init banjubu $ go get github.com/gin-gonic/gin $ go get github.com/99designs/gqlgen $ printf '// +build tools\npackage tools\nimport _ "github.com/99designs/gqlgen"' | gofmt > tools.go $ go run github.com/99designs/gqlgen init $ rm -rf server.go 2. main.go package main import ( "banjubu/graph" "banjubu/graph/generated" "github.com/99designs/gqlgen/graphql/handler.. 2022. 5. 19. [Golang] 단숨에 GraphQL 적용하기 [gqlgen] 새로운 폴더 만들고 시작할께요. 1. 설치 $ go mod init banjubu $ go get github.com/99designs/gqlgen $ printf '// +build tools\npackage tools\nimport _ "github.com/99designs/gqlgen"' | gofmt > tools.go $ go run github.com/99designs/gqlgen init $ go run server.go 2. graph/resolver.go package graph import "banjubu/graph/model" // This file will not be regenerated automatically. // // It serves as dependency injecti.. 2022. 5. 19. [Golang] Supervisor로 데몬 실행하기 Supervisor: Node.js 진영의 PM2와 유사한 프로세스 컨트롤러. 1. Go 빌드 > main 파일 생성 $ go build main.go 2. Supervisor 설치 $ pip install supervisor 3. supervisor.conf [supervisord] [supervisorctl] serverurl=http://127.0.0.1:9001 [inet_http_server] port = 127.0.0.1:9001 [program:ginTest] command = ./main autostart = true autorestart = true startsecs = 1 4. 실행 $ supervisord -c supervisor.conf 5. 확인 http://localhost:90.. 2022. 5. 18. [Golang] AWS CloudFront > 무효화 (CreateInvalidation) 1. S3 업로드 2022.05.18 - [IT 인터넷/Golang] - [Golang] 파일 업로드 > S3 2022. 5. 18. [Golang] 파일 업로드 > S3 1. 패키지 다운로드 $ go get github.com/aws/aws-sdk-go-v2/aws $ go get github.com/aws/aws-sdk-go-v2/config 2. 주요 코드 // 업로드된 파일 정보 imageFile, imageFileHeader, _ := c.Request.FormFile("imageFile") // 바이트 버퍼로 변환 buf := make([]byte, imageFileHeader.Size) imageFile.Read(buf) // AWS 세션 생성 session, err := session.NewSession(&aws.Config{ Region: aws.String("ap-northeast-2"), Credentials: credentials.NewStaticCr.. 2022. 5. 18. [Golang] Gin + MySQL 1. .env MYSQL_HOST = "" MYSQL_USER = "" MYSQL_PASSWORD = "" MYSQL_DBNAME = "" MYSQL_PROTOCOL = "tcp" MYSQL_PORT = 3306 2. go.mod module myproject/main go 1.16 require ( github.com/gin-contrib/cors v1.3.1 // indirect github.com/gin-gonic/gin v1.7.7 // indirect github.com/go-playground/validator/v10 v10.11.0 // indirect github.com/go-sql-driver/mysql v1.6.0 // indirect github.com/golang/protobuf v.. 2022. 5. 16. [Golang] Hello Gin 1. 설치 $ go get -u github.com/gin-gonic/gin 2. main.go package main import "github.com/gin-gonic/gin" func main() { r := gin.Default() r.GET("/echo", func(c *gin.Context) { msg := c.DefaultQuery("msg", "Banjubu") c.JSON(200, gin.H{ "message": msg, }) }) r.Run(":8080") } 3. 실행 $ go run main.go 4. 확인 http://localhost:8080/echo {"message":"Banjubu"} http://localhost:8080/echo?msg=Golang {"message":".. 2022. 5. 16. [Golang] echo 샘플2 한 줄 받는 샘플. 2022.05.15 - [IT 인터넷/Golang] - [Golang] echo 샘플 [Golang] echo 샘플 문자열을 입력하면 그대로 출력하는 예제에요. stdin.ReadString 은 주어진 delimeter 까지의 문자열을 돌려줘요. package main import ( "bufio" "fmt" "os" ) func main() { stdin := bufio.NewReader(os.Stdin).. banjubu.tistory.com 여러 줄을 받아볼께요. 엔터만 치면 빠져나가요. package main import ( "bufio" "fmt" "os" ) func main() { sc := bufio.NewScanner(os.Stdin) for sc.Scan() { tx.. 2022. 5. 15. [Golang] echo 샘플 문자열을 입력하면 그대로 출력하는 예제에요. stdin.ReadString 은 주어진 delimeter 까지의 문자열을 돌려줘요. package main import ( "bufio" "fmt" "os" ) func main() { stdin := bufio.NewReader(os.Stdin) s, _ := stdin.ReadString('\n') fmt.Println(s) } 결과. $ go run main.go Banjubu Banjubu 만약 s, _ := stdin.ReadString('=') 이렇게 했다면. $ go run main.go Banjubu=Banjubu Banjubu= 여러 줄 받는 샘플. 2022.05.15 - [IT 인터넷/Golang] - [Golang] echo 샘플2 [Go.. 2022. 5. 15. [Golang] 텍스트 파일 읽고 랜덤 아이템 추출하기 list.txt 김씨 이씨 박씨 강씨 최씨 송씨 홍씨 main.go package main import ( "bufio" "fmt" "math/rand" "os" "time" ) func main() { file, _ := os.Open("list.txt") defer file.Close() result := make([]string, 0) scanner := bufio.NewScanner(file) for scanner.Scan() { result = append(result, scanner.Text()) } rand.Seed(time.Now().UnixNano()) for i := 0; i < 3; i++ { rnd := rand.Intn(len(result)) fmt.Println(result[rn.. 2022. 4. 29. [Golang] 웹사이트 헬스 체크 :: Website Health Check 노마드 강의 듣고 기억을 더듬어 코딩했어요. 그래서 코드가 조금 달라요. 일단 고루틴을 안 썼더니 평균 3.5초가 나오네요. package main import ( "fmt" "net/http" "time" ) var urls []string = []string{ "https://yeastudio.kr", "https://google.com", "https://naver.com", "https://yahoo.com", "https://kakao.com", "https://facebook.com", "https://twitter.com", } func main() { tm := time.Now() for _, v := range urls { res, err := checkURL(v) fmt.Println(.. 2021. 5. 5. 이전 1 2 다음 728x90 반응형 LIST