일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- Jupyter
- port forwarding
- appium
- perfect
- create table
- postgresql
- ssh
- 실행권한
- Jupyter Notebook
- nohup
- STF_PortForwarding
- centos
- sshpass
- STF
- rethinkdb
- postgres
- PYTHON
- nGrinder
- mysql
- nmap
- openpyxl
- 28015
- insert
- ftp
- GoCD
- kitura
- SWIFT
- ubuntu
- appium server
- Materials
- Today
- Total
목록분류 전체보기 (323)
don't stop believing
Gin에서 mysql의 CURD 예제를 확인해 보겠습니다.https://gist.github.com/rsj217/26492af115a083876570f003c64df118#file-golang-gin-mysql-curd-go-L99 먼저 go-sql-driver의 mysql package를 다운 받습니다. $ go get -u github.com/go-sql-driver/mysql go-sql-driver/mysql에 대한 설명은 아래 링크에서 확인하세요.https://github.com/go-sql-driver/mysql 이번엔 mysql에 테이블을 만들어 줍니다.저는 아래와 같이 간단한 테이블을 하나 만들었습니다. CREATE TABLE IF NOT EXISTS person( id INT AUTO_I..
API 서버를 만드는데있어 문서화는 필수입니다.Gin에서 Swagger를 사용하는 걸 확인해 보겠습니다.https://github.com/swaggo/gin-swagger 먼저 Go에서 swag를 사용할 수 있게 source code를 다운로드 합니다. $ go get -u github.com/swaggo/swag/cmd/swag swag가 잘 다운로드 돼었는지 확인해 봅니다. $ ll $GOPATH/src/github.com/swaggo total 0 drwxr-xr-x 3 tongchunkim staff 96B 3 4 17:58 . drwxr-xr-x 30 tongchunkim staff 960B 3 4 17:58 .. drwxr-xr-x 34 tongchunkim staff 1.1K 3 4 17:5..
이번에는 route를 그룹핑하는 기능입니다.https://github.com/gin-gonic/gin#grouping-routes 사용은 간단합니다. 하위 그룹으로 묶을 route를 Group()으로 묶으면 됩니다.바로 예제 코드를 보면 아래와 같습니다. package main import ( "github.com/gin-gonic/gin" ) func setupRouter() *gin.Engine { // Disable Console Color // gin.DisableConsoleColor() r := gin.Default() // Simple group: v1 v1 := r.Group("/v1") { v1.POST("/login", loginEndpoint) v1.POST("/submit", sub..
Gin의 기능을 확인하다 아래와 같은 코드를 확인확인했습니다.r.MaxMultipartMemory = 8 > 3 // 01110000인 비트를 오른쪽으로 3번 이동합니다. fmt.Printf("%08b", b) // 비트로 확인하면 00001110이 되고 정수로는 14입니다. 만약 오른쪽으로 5번 이동하게 되면 00000011이 되고 정수로는 13이 됩니다. 이제 Gin에서 봤던 메모리 설정 코드입니다.파일 업로드를 하는데 업로드되는 파일의 사이즈를 메모리에 할당 할 수 있도록 설정을 하게 됩니다. // Set a lower memory limit for multipart forms (default is 32 MiB) r.MaxMultipartMemory = 8
이번에는 파일 업로드를 해보겠습니다.https://github.com/gin-gonic/gin#upload-files 파일 하나 올리는 것과, 여러개를 동시에 올리는 것을 해보겠습니다.우선 파일을 올릴 수 있는 html 파일을 아래와 같이 만들어 줍니다. 저는 uploadfiles.html로 만들었습니다.위치는 templates 폴더 안에 위치합니다. page: {{ .page }} upload file: 이번에는 server.go 내용입니다. package main import ( "fmt" "log" "net/http" "path/filepath" "github.com/gin-gonic/gin" ) func setupRouter() *gin.Engine { // Disable Console Color..
간혹 네트워크 구성도를 그릴때가 있습니다.보통 PPT로 그리려고 하는데 그럴때 마다 네트워크 아이콘을 찾는게 일이었습니다. Gliffy를 쓰니 편하네요.Google Chrome Extension으로도 있습니다.https://chrome.google.com/webstore/detail/gliffy-diagrams/bhmicilclplefnflapjmnngmkkkkpfad?hl=en Gliffy에서 그리고 스크린샷 떠서 ppt에 추가하면 편합니다.gliffy 파일로 저장도 할 수 있습니다.
query string이나 post로 넘기는 데이터를 map 형식으로 사용하는 것은 이번에 처음 알게 되었습니다.https://github.com/gin-gonic/gin#map-as-querystring-or-postform-parameters 아래와 같이 ids[a]=123 그리고 ids[b]=hello 처럼 사용할 수 있습니다./post?ids[a]=1234&ids[b]=hello 마찬가지로 html의 form에서도 map 형식의 데이터를 넘길 수 있습니다. 이번에는 tamplate을 사용해 html 페이지를 실행하겠습니다.먼저 tamplates라는 폴더를 만들고 그 안에 note.html 파일을 만들어 줍니다. 그리고 아래와 같이 작성합니다. page: {{ .page }} first name: ..
지난 Posting에 이어 하나 더 해보겠습니다.Multipart/Urlencoded Form html 페이지의 form tag 중 action의 값인 url에 query string이 붙어있는 경우 입니다.https://github.com/gin-gonic/gin#another-example-query--post-form message: nick: form의 action으로 넘기는 url에 주렁주렁 query string이 달려 있습니다.http://localhost:8080/form_post_with_querystring?id=dejavu&page=34 이럴때 query string의 parameter와 form tag로 전달되는 post 데이터를 같이 받는 방법입니다. package main imp..
html의 form tag로 데이터를 보내고 확인해 보겠습니다.https://github.com/gin-gonic/gin#multiparturlencoded-form 먼저 아래와같이 html 페이지가 있다가 가정해 보겠습니다. message: nick: form tag의 action은 데이터를 넘기는 url입니다. method는 post로 넘어갑니다.넘기는 데이터로는 message와 nick이 있습니다.실행하면 아래와 같은 화면입니다.이제 go 코드 입니다. package main import ( "github.com/gin-gonic/gin" ) func setupRouter() *gin.Engine { // Disable Console Color // gin.DisableConsoleColor() r..
url의 ? 뒤에 따라오는 Query String 처리 입니다.이번 예제는 ? 뒤에 firstname 과 lastname이 map 형태의 parameter로 전달되게 됩니다.https://github.com/gin-gonic/gin#querystring-parameters package main import ( "github.com/gin-gonic/gin" ) func setupRouter() *gin.Engine { // Disable Console Color // gin.DisableConsoleColor() r := gin.Default() r.GET("/welcome", welcomeQueryString) return r } // Query string parameters are parsed u..