{"url":"https://api.github.com/gists/4e35ed9546f379a3ef0583644d760bce","forks_url":"https://api.github.com/gists/4e35ed9546f379a3ef0583644d760bce/forks","commits_url":"https://api.github.com/gists/4e35ed9546f379a3ef0583644d760bce/commits","id":"4e35ed9546f379a3ef0583644d760bce","node_id":"MDQ6R2lzdDRlMzVlZDk1NDZmMzc5YTNlZjA1ODM2NDRkNzYwYmNl","git_pull_url":"https://gist.github.com/4e35ed9546f379a3ef0583644d760bce.git","git_push_url":"https://gist.github.com/4e35ed9546f379a3ef0583644d760bce.git","html_url":"https://gist.github.com/michaellihs/4e35ed9546f379a3ef0583644d760bce","files":{"go-cheat-sheet.md":{"filename":"go-cheat-sheet.md","type":"text/markdown","language":"Markdown","raw_url":"https://gist.githubusercontent.com/michaellihs/4e35ed9546f379a3ef0583644d760bce/raw/9f71134127614eafcd68d5ef62498652374b4cfd/go-cheat-sheet.md","size":2842,"truncated":false,"content":"Go Cheat Sheet\n==============\n\nInstall Go on Mac\n-----------------\n\n> Following the instructions from https://golang.org/doc/install\n\n1. Download https://golang.org/doc/install?download=go1.13.3.darwin-amd64.pkg\n1. Run installer\n\n> if you don't set a `$GOPATH`, the default path is `~/go`\n\n\nGo Modules\n----------\n\n### Basic Commands\n\n> Remember to work outside of your `$GOPATH`!\n\n* initialize a new module\n\n    ```bash\n    export GO111MODULE=on\n    go mod init\n    ```\n    \n  * this will create a `go.mod` file in your current directory.\n\n* add a new dependency\n\n  * in your `.go` file\n  \n     ```go\n     import rsc.io/quote\n     ```\n  \n  * build your code\n  \n     ```bash\n     go build\n     ```\n     \n  * check your `go.mod` file, it will only show the `rsc.io/quote` module\n  * check transitive dependencies with\n  \n     ```bash\n     go list -m all\n     ```\n     \n* list versions\n  \n   ```bash\n   go list -m -versions rsc.io/sampler\n   ```\n   \n* upgrade modules\n\n  * check available update for all modules via\n  \n     ```bash\n     go list -m -u all\n     ```\n     \n  * update one specific package via (will update your dependency in `go.mod`)\n  \n     ```bash\n     go get -u golang.org/x/text v0.3.0\n     ```\n     \n  * upgrade all modules\n  \n     > might not be a good idea though!\n  \n     ```bash\n     go get -u\n     ```\n     \n* downgrading\n\n  * \n  \n* use local changes\n\n   ```bash\n   # assume the local copy of your module is in ../quote\n   go mod edit -replace 'rsc.io/quote=../quote'\n   ``` \n   \n* use remote fork / specific tag\n\n   ```bash\n   go mod edit -replace 'rsc.io/quote=github.com/myitcv/london-gophers-quote-fork@0.0.0-myfork'\n   ```\n     \n* testing\n\n   * all modules involved in your release (test all modules plus transitive dependencies)\n\n      ```bash\n      go test -short all\n      ```\n   \n   * test a single module package\n   \n      ```bash\n      go test rsc.io/quote/...\n      ```\n  \n### Convert an existing Project\n\n> Working outside of the `$GOPATH`\n\n* Initialize Go modules inside the project directory\n\n   ```bash\n   go mod init\n   go mod tidy\n   ``` \n\n### References for Go mdules\n\n* [Go Modules Documentation on GitHub](https://github.com/golang/go/wiki/Modules#gomod)\n* https://www.youtube.com/watch?v=6MbIzJmLz6Q\n\n\nLanguage Details\n----------------\n\n* [Missing Generics in Go](https://appliedgo.net/generics/)\n\n\nGo Dependency Management\n------------------------\n\n* [Fetching Private Dependencies with Go Modules](https://medium.com/@tim_raymond/fetching-private-dependencies-with-go-modules-1d65afe47c62)\n\n\nTesting with Go\n---------------\n\n* [Tests for Go CLI Applications](http://lucapette.me/writing-integration-tests-for-a-go-cli-application)\n* [Ginkgo](https://onsi.github.io/ginkgo/)\n* [GoMock](https://github.com/golang/mock)\n\n\nLearning Go\n-----------\n\n* [Pacman with Go](https://github.com/danicat/pacgo)\n","encoding":"utf-8"}},"public":true,"created_at":"2018-01-03T12:49:37Z","updated_at":"2024-02-20T17:39:59Z","description":"Go Cheat Sheet","comments":0,"user":null,"comments_enabled":true,"comments_url":"https://api.github.com/gists/4e35ed9546f379a3ef0583644d760bce/comments","owner":{"login":"michaellihs","id":575011,"node_id":"MDQ6VXNlcjU3NTAxMQ==","avatar_url":"https://avatars.githubusercontent.com/u/575011?v=4","gravatar_id":"","url":"https://api.github.com/users/michaellihs","html_url":"https://github.com/michaellihs","followers_url":"https://api.github.com/users/michaellihs/followers","following_url":"https://api.github.com/users/michaellihs/following{/other_user}","gists_url":"https://api.github.com/users/michaellihs/gists{/gist_id}","starred_url":"https://api.github.com/users/michaellihs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaellihs/subscriptions","organizations_url":"https://api.github.com/users/michaellihs/orgs","repos_url":"https://api.github.com/users/michaellihs/repos","events_url":"https://api.github.com/users/michaellihs/events{/privacy}","received_events_url":"https://api.github.com/users/michaellihs/received_events","type":"User","user_view_type":"public","site_admin":false},"forks":[{"url":"https://api.github.com/gists/afbff9e62bee8046160b715f84bb7ad5","user":{"login":"long25vn","id":31624384,"node_id":"MDQ6VXNlcjMxNjI0Mzg0","avatar_url":"https://avatars.githubusercontent.com/u/31624384?v=4","gravatar_id":"","url":"https://api.github.com/users/long25vn","html_url":"https://github.com/long25vn","followers_url":"https://api.github.com/users/long25vn/followers","following_url":"https://api.github.com/users/long25vn/following{/other_user}","gists_url":"https://api.github.com/users/long25vn/gists{/gist_id}","starred_url":"https://api.github.com/users/long25vn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/long25vn/subscriptions","organizations_url":"https://api.github.com/users/long25vn/orgs","repos_url":"https://api.github.com/users/long25vn/repos","events_url":"https://api.github.com/users/long25vn/events{/privacy}","received_events_url":"https://api.github.com/users/long25vn/received_events","type":"User","user_view_type":"public","site_admin":false,"name":"Nguyễn Thành Long","company":null,"blog":"","location":null,"email":null,"hireable":null,"bio":null,"twitter_username":null,"public_repos":71,"public_gists":41,"followers":5,"following":1,"created_at":"2017-09-04T14:04:51Z","updated_at":"2025-05-26T08:36:38Z"},"id":"afbff9e62bee8046160b715f84bb7ad5","created_at":"2021-05-29T09:40:22Z","updated_at":"2021-05-31T15:34:48Z"},{"url":"https://api.github.com/gists/e1cd873c123a6b9afb7b1a258ae6313e","user":{"login":"mkjiau","id":5200038,"node_id":"MDQ6VXNlcjUyMDAwMzg=","avatar_url":"https://avatars.githubusercontent.com/u/5200038?v=4","gravatar_id":"","url":"https://api.github.com/users/mkjiau","html_url":"https://github.com/mkjiau","followers_url":"https://api.github.com/users/mkjiau/followers","following_url":"https://api.github.com/users/mkjiau/following{/other_user}","gists_url":"https://api.github.com/users/mkjiau/gists{/gist_id}","starred_url":"https://api.github.com/users/mkjiau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkjiau/subscriptions","organizations_url":"https://api.github.com/users/mkjiau/orgs","repos_url":"https://api.github.com/users/mkjiau/repos","events_url":"https://api.github.com/users/mkjiau/events{/privacy}","received_events_url":"https://api.github.com/users/mkjiau/received_events","type":"User","user_view_type":"public","site_admin":false,"name":"MK","company":null,"blog":"","location":null,"email":"mk@jiau.dev","hireable":null,"bio":null,"twitter_username":null,"public_repos":88,"public_gists":11,"followers":42,"following":6,"created_at":"2013-08-09T21:01:50Z","updated_at":"2026-03-31T17:06:49Z"},"id":"e1cd873c123a6b9afb7b1a258ae6313e","created_at":"2021-11-06T01:27:10Z","updated_at":"2021-11-06T01:27:10Z"},{"url":"https://api.github.com/gists/481f0a63b191fdcac7066cd2d79d5b65","user":{"login":"rts0101","id":607321,"node_id":"MDQ6VXNlcjYwNzMyMQ==","avatar_url":"https://avatars.githubusercontent.com/u/607321?v=4","gravatar_id":"","url":"https://api.github.com/users/rts0101","html_url":"https://github.com/rts0101","followers_url":"https://api.github.com/users/rts0101/followers","following_url":"https://api.github.com/users/rts0101/following{/other_user}","gists_url":"https://api.github.com/users/rts0101/gists{/gist_id}","starred_url":"https://api.github.com/users/rts0101/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rts0101/subscriptions","organizations_url":"https://api.github.com/users/rts0101/orgs","repos_url":"https://api.github.com/users/rts0101/repos","events_url":"https://api.github.com/users/rts0101/events{/privacy}","received_events_url":"https://api.github.com/users/rts0101/received_events","type":"User","user_view_type":"public","site_admin":false,"name":"Ryan Schneider","company":"Verint","blog":"https://www.verint.com/","location":null,"email":"rts0101@gmail.com","hireable":null,"bio":null,"twitter_username":null,"public_repos":17,"public_gists":1,"followers":9,"following":60,"created_at":"2011-02-08T18:33:27Z","updated_at":"2026-02-22T05:03:06Z"},"id":"481f0a63b191fdcac7066cd2d79d5b65","created_at":"2023-02-01T04:30:00Z","updated_at":"2023-02-01T04:30:00Z"}],"history":[{"user":{"login":"michaellihs","id":575011,"node_id":"MDQ6VXNlcjU3NTAxMQ==","avatar_url":"https://avatars.githubusercontent.com/u/575011?v=4","gravatar_id":"","url":"https://api.github.com/users/michaellihs","html_url":"https://github.com/michaellihs","followers_url":"https://api.github.com/users/michaellihs/followers","following_url":"https://api.github.com/users/michaellihs/following{/other_user}","gists_url":"https://api.github.com/users/michaellihs/gists{/gist_id}","starred_url":"https://api.github.com/users/michaellihs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaellihs/subscriptions","organizations_url":"https://api.github.com/users/michaellihs/orgs","repos_url":"https://api.github.com/users/michaellihs/repos","events_url":"https://api.github.com/users/michaellihs/events{/privacy}","received_events_url":"https://api.github.com/users/michaellihs/received_events","type":"User","user_view_type":"public","site_admin":false},"version":"5b37e6d8102c1ff3a950c8ee3eb116bcbc28cb71","committed_at":"2019-12-15T17:56:06Z","change_status":{"total":10,"additions":10,"deletions":0},"url":"https://api.github.com/gists/4e35ed9546f379a3ef0583644d760bce/5b37e6d8102c1ff3a950c8ee3eb116bcbc28cb71"},{"user":{"login":"michaellihs","id":575011,"node_id":"MDQ6VXNlcjU3NTAxMQ==","avatar_url":"https://avatars.githubusercontent.com/u/575011?v=4","gravatar_id":"","url":"https://api.github.com/users/michaellihs","html_url":"https://github.com/michaellihs","followers_url":"https://api.github.com/users/michaellihs/followers","following_url":"https://api.github.com/users/michaellihs/following{/other_user}","gists_url":"https://api.github.com/users/michaellihs/gists{/gist_id}","starred_url":"https://api.github.com/users/michaellihs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaellihs/subscriptions","organizations_url":"https://api.github.com/users/michaellihs/orgs","repos_url":"https://api.github.com/users/michaellihs/repos","events_url":"https://api.github.com/users/michaellihs/events{/privacy}","received_events_url":"https://api.github.com/users/michaellihs/received_events","type":"User","user_view_type":"public","site_admin":false},"version":"fc771996d85313ab303adc300db934bdff6132ac","committed_at":"2019-12-10T20:42:36Z","change_status":{"total":11,"additions":11,"deletions":0},"url":"https://api.github.com/gists/4e35ed9546f379a3ef0583644d760bce/fc771996d85313ab303adc300db934bdff6132ac"},{"user":{"login":"michaellihs","id":575011,"node_id":"MDQ6VXNlcjU3NTAxMQ==","avatar_url":"https://avatars.githubusercontent.com/u/575011?v=4","gravatar_id":"","url":"https://api.github.com/users/michaellihs","html_url":"https://github.com/michaellihs","followers_url":"https://api.github.com/users/michaellihs/followers","following_url":"https://api.github.com/users/michaellihs/following{/other_user}","gists_url":"https://api.github.com/users/michaellihs/gists{/gist_id}","starred_url":"https://api.github.com/users/michaellihs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaellihs/subscriptions","organizations_url":"https://api.github.com/users/michaellihs/orgs","repos_url":"https://api.github.com/users/michaellihs/repos","events_url":"https://api.github.com/users/michaellihs/events{/privacy}","received_events_url":"https://api.github.com/users/michaellihs/received_events","type":"User","user_view_type":"public","site_admin":false},"version":"ad3b64c6a44ad73fb11c9aa628613b6a143ea436","committed_at":"2019-12-10T20:38:09Z","change_status":{"total":62,"additions":62,"deletions":0},"url":"https://api.github.com/gists/4e35ed9546f379a3ef0583644d760bce/ad3b64c6a44ad73fb11c9aa628613b6a143ea436"},{"user":{"login":"michaellihs","id":575011,"node_id":"MDQ6VXNlcjU3NTAxMQ==","avatar_url":"https://avatars.githubusercontent.com/u/575011?v=4","gravatar_id":"","url":"https://api.github.com/users/michaellihs","html_url":"https://github.com/michaellihs","followers_url":"https://api.github.com/users/michaellihs/followers","following_url":"https://api.github.com/users/michaellihs/following{/other_user}","gists_url":"https://api.github.com/users/michaellihs/gists{/gist_id}","starred_url":"https://api.github.com/users/michaellihs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaellihs/subscriptions","organizations_url":"https://api.github.com/users/michaellihs/orgs","repos_url":"https://api.github.com/users/michaellihs/repos","events_url":"https://api.github.com/users/michaellihs/events{/privacy}","received_events_url":"https://api.github.com/users/michaellihs/received_events","type":"User","user_view_type":"public","site_admin":false},"version":"2b865332412390e62656eeefc5b4bb255eb4a4b4","committed_at":"2019-12-10T20:17:59Z","change_status":{"total":32,"additions":32,"deletions":0},"url":"https://api.github.com/gists/4e35ed9546f379a3ef0583644d760bce/2b865332412390e62656eeefc5b4bb255eb4a4b4"},{"user":{"login":"michaellihs","id":575011,"node_id":"MDQ6VXNlcjU3NTAxMQ==","avatar_url":"https://avatars.githubusercontent.com/u/575011?v=4","gravatar_id":"","url":"https://api.github.com/users/michaellihs","html_url":"https://github.com/michaellihs","followers_url":"https://api.github.com/users/michaellihs/followers","following_url":"https://api.github.com/users/michaellihs/following{/other_user}","gists_url":"https://api.github.com/users/michaellihs/gists{/gist_id}","starred_url":"https://api.github.com/users/michaellihs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaellihs/subscriptions","organizations_url":"https://api.github.com/users/michaellihs/orgs","repos_url":"https://api.github.com/users/michaellihs/repos","events_url":"https://api.github.com/users/michaellihs/events{/privacy}","received_events_url":"https://api.github.com/users/michaellihs/received_events","type":"User","user_view_type":"public","site_admin":false},"version":"acf63824ee843b46ef5e048b48d4d31879956378","committed_at":"2019-10-21T14:35:44Z","change_status":{"total":8,"additions":7,"deletions":1},"url":"https://api.github.com/gists/4e35ed9546f379a3ef0583644d760bce/acf63824ee843b46ef5e048b48d4d31879956378"},{"user":{"login":"michaellihs","id":575011,"node_id":"MDQ6VXNlcjU3NTAxMQ==","avatar_url":"https://avatars.githubusercontent.com/u/575011?v=4","gravatar_id":"","url":"https://api.github.com/users/michaellihs","html_url":"https://github.com/michaellihs","followers_url":"https://api.github.com/users/michaellihs/followers","following_url":"https://api.github.com/users/michaellihs/following{/other_user}","gists_url":"https://api.github.com/users/michaellihs/gists{/gist_id}","starred_url":"https://api.github.com/users/michaellihs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaellihs/subscriptions","organizations_url":"https://api.github.com/users/michaellihs/orgs","repos_url":"https://api.github.com/users/michaellihs/repos","events_url":"https://api.github.com/users/michaellihs/events{/privacy}","received_events_url":"https://api.github.com/users/michaellihs/received_events","type":"User","user_view_type":"public","site_admin":false},"version":"4f03090673a2015cf11302e3dcbee17268363e8a","committed_at":"2019-10-21T14:33:27Z","change_status":{"total":2,"additions":1,"deletions":1},"url":"https://api.github.com/gists/4e35ed9546f379a3ef0583644d760bce/4f03090673a2015cf11302e3dcbee17268363e8a"},{"user":{"login":"michaellihs","id":575011,"node_id":"MDQ6VXNlcjU3NTAxMQ==","avatar_url":"https://avatars.githubusercontent.com/u/575011?v=4","gravatar_id":"","url":"https://api.github.com/users/michaellihs","html_url":"https://github.com/michaellihs","followers_url":"https://api.github.com/users/michaellihs/followers","following_url":"https://api.github.com/users/michaellihs/following{/other_user}","gists_url":"https://api.github.com/users/michaellihs/gists{/gist_id}","starred_url":"https://api.github.com/users/michaellihs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaellihs/subscriptions","organizations_url":"https://api.github.com/users/michaellihs/orgs","repos_url":"https://api.github.com/users/michaellihs/repos","events_url":"https://api.github.com/users/michaellihs/events{/privacy}","received_events_url":"https://api.github.com/users/michaellihs/received_events","type":"User","user_view_type":"public","site_admin":false},"version":"a838c6c1543f97cbc05b1a3e050dc89affbc6ba0","committed_at":"2019-10-21T11:53:44Z","change_status":{"total":6,"additions":6,"deletions":0},"url":"https://api.github.com/gists/4e35ed9546f379a3ef0583644d760bce/a838c6c1543f97cbc05b1a3e050dc89affbc6ba0"},{"user":{"login":"michaellihs","id":575011,"node_id":"MDQ6VXNlcjU3NTAxMQ==","avatar_url":"https://avatars.githubusercontent.com/u/575011?v=4","gravatar_id":"","url":"https://api.github.com/users/michaellihs","html_url":"https://github.com/michaellihs","followers_url":"https://api.github.com/users/michaellihs/followers","following_url":"https://api.github.com/users/michaellihs/following{/other_user}","gists_url":"https://api.github.com/users/michaellihs/gists{/gist_id}","starred_url":"https://api.github.com/users/michaellihs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaellihs/subscriptions","organizations_url":"https://api.github.com/users/michaellihs/orgs","repos_url":"https://api.github.com/users/michaellihs/repos","events_url":"https://api.github.com/users/michaellihs/events{/privacy}","received_events_url":"https://api.github.com/users/michaellihs/received_events","type":"User","user_view_type":"public","site_admin":false},"version":"ae0bf83446237be9df99faef3045966840a0b745","committed_at":"2019-10-21T08:35:13Z","change_status":{"total":3,"additions":2,"deletions":1},"url":"https://api.github.com/gists/4e35ed9546f379a3ef0583644d760bce/ae0bf83446237be9df99faef3045966840a0b745"},{"user":{"login":"michaellihs","id":575011,"node_id":"MDQ6VXNlcjU3NTAxMQ==","avatar_url":"https://avatars.githubusercontent.com/u/575011?v=4","gravatar_id":"","url":"https://api.github.com/users/michaellihs","html_url":"https://github.com/michaellihs","followers_url":"https://api.github.com/users/michaellihs/followers","following_url":"https://api.github.com/users/michaellihs/following{/other_user}","gists_url":"https://api.github.com/users/michaellihs/gists{/gist_id}","starred_url":"https://api.github.com/users/michaellihs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaellihs/subscriptions","organizations_url":"https://api.github.com/users/michaellihs/orgs","repos_url":"https://api.github.com/users/michaellihs/repos","events_url":"https://api.github.com/users/michaellihs/events{/privacy}","received_events_url":"https://api.github.com/users/michaellihs/received_events","type":"User","user_view_type":"public","site_admin":false},"version":"19aee9edf2030f3ddfe191ae7b55eccad4251d6c","committed_at":"2019-10-20T07:26:17Z","change_status":{"total":8,"additions":8,"deletions":0},"url":"https://api.github.com/gists/4e35ed9546f379a3ef0583644d760bce/19aee9edf2030f3ddfe191ae7b55eccad4251d6c"},{"user":{"login":"michaellihs","id":575011,"node_id":"MDQ6VXNlcjU3NTAxMQ==","avatar_url":"https://avatars.githubusercontent.com/u/575011?v=4","gravatar_id":"","url":"https://api.github.com/users/michaellihs","html_url":"https://github.com/michaellihs","followers_url":"https://api.github.com/users/michaellihs/followers","following_url":"https://api.github.com/users/michaellihs/following{/other_user}","gists_url":"https://api.github.com/users/michaellihs/gists{/gist_id}","starred_url":"https://api.github.com/users/michaellihs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaellihs/subscriptions","organizations_url":"https://api.github.com/users/michaellihs/orgs","repos_url":"https://api.github.com/users/michaellihs/repos","events_url":"https://api.github.com/users/michaellihs/events{/privacy}","received_events_url":"https://api.github.com/users/michaellihs/received_events","type":"User","user_view_type":"public","site_admin":false},"version":"980273ca47142de5e1d8ebae64ad7defb60512c3","committed_at":"2018-01-03T12:49:36Z","change_status":{"total":15,"additions":15,"deletions":0},"url":"https://api.github.com/gists/4e35ed9546f379a3ef0583644d760bce/980273ca47142de5e1d8ebae64ad7defb60512c3"}],"truncated":false}