{"id":18794994,"url":"https://github.com/fbac/go-resources","last_synced_at":"2025-06-13T05:04:54.929Z","repository":{"id":37498113,"uuid":"504823661","full_name":"fbac/go-resources","owner":"fbac","description":"Personal training, braindump and cheatsheet repository","archived":false,"fork":false,"pushed_at":"2022-07-12T21:46:22.000Z","size":1336,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-21T16:49:45.555Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fbac.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-18T11:23:38.000Z","updated_at":"2022-06-21T15:47:35.000Z","dependencies_parsed_at":"2022-07-13T01:40:33.068Z","dependency_job_id":null,"html_url":"https://github.com/fbac/go-resources","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fbac/go-resources","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fbac%2Fgo-resources","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fbac%2Fgo-resources/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fbac%2Fgo-resources/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fbac%2Fgo-resources/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fbac","download_url":"https://codeload.github.com/fbac/go-resources/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fbac%2Fgo-resources/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259584816,"owners_count":22880200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T21:32:10.262Z","updated_at":"2025-06-13T05:04:54.905Z","avatar_url":"https://github.com/fbac.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fbac's go resources\n\n- [fbac's go resources](#fbacs-go-resources)\n  - [Disclaimer](#disclaimer)\n  - [Useful links](#useful-links)\n  - [Basics](#basics)\n    - [Personal coding guidelines](#personal-coding-guidelines)\n    - [Creating a new project](#creating-a-new-project)\n    - [Command Line](#command-line)\n  - [Code samples](#code-samples)\n    - [Types](#types)\n    - [Conditions and loops](#conditions-and-loops)\n  - [TODO](#todo)\n\n## Disclaimer\n\nThis documentation and resources have been collected through the time I've been learning and working with golang, since some years ago.\n\nIt's been in my personal laptop for a million years, so in order to get rid of that SPOF I'm creating this repository. If someone finds anything helpful in here that'd be awesome.\n\nI've been updating it from time to time, with the simple purpose of serving as a cheatsheet and braindump some knowledge along the way, as I rarely rely on my (very) volatile memory. Hence this is, by no means, aimed to substitute official go documentation, to be a professional source of knowledge or to be maintained as it's and will be used for personal uses and fast fact-checker.\n\n## Useful links\n\n- [Official documentation](https://go.dev/doc/)\n- [Effective go](https://go.dev/doc/effective_go)\n- [Standard library](https://pkg.go.dev/std)\n- [The Go Blog](https://go.dev/blog/all)\n- [Go by Example](https://gobyexample.com)\n- [golang-book](https://www.golang-book.com/)\n- [web applications with Go](https://astaxie.gitbooks.io/build-web-application-with-golang/content/en/index.html)\n\n## Basics\n\n- Go is a statically typed compiled general-purpose language.\n- Built-in concurrency through goroutines and channels to communicate them.\n- Built-in garbage collection and runtime reflection.\n- Powerful standard library and modules.\n- Control flow: sequential, loop (iterative), conditional.\n\n### Personal coding guidelines\n\n- `go.mod` and `go.sum` **have** to be versioned.\n- Always BET: Benchmark, Example, Test!\n- Always format and check the code to meet the standard Go criteria: `gofmt`, `govet`, `golint`\n- Always test code and create cover profiles: `go test`, `go test -cover`, `go test -coverprofile=example.out`, `go tool cover -html=example.out`\n- Declare variables only when **really** needed, trying always to reduce the memory footprint.\n- Keep the scope for each variable as narrow as possible.\n  - Always use the short declaration operator inside a code block to declare and assign a value to a variable.\n  - If a package level variable is needed, declare the var outside main using the `var \u003cname\u003e \u003ctype\u003e` statement.\n  - be careful when returning vars from funcs to prevent variables avoiding GC.\n- Don't forget the `init()` function, sometimes it's very useful, such as initializing imported packages.\n- defer + goroutines are best friends. Use with caution.\n- Think about memory: it's usually more performant to allocate everything that you need instead of having the runtime do it dynamically. Create data structures once, not in loops if possible.\n- Always write docs and examples.\n  - Use docs.go for package docs.\n  - Use Examples in test files to write example usage.\n  - Check with `go doc [\u003cpkg\u003e.][\u003csym\u003e.]\u003cmethod\u003e` and `godoc`, `godoc -http=:PORT`\n  - Source code with `go doc -src fmt Println`, `go doc -src fmt`, `go doc cmd/go`\n\n### Creating a new project\n\n- `go mod`\n- `go mod init \u003cpath\u003e`: create new project\n- `go mod tidy`\n\n### Command Line\n\n- `go install`\n\n## Code samples\n\n### Types\n\n- [arrays](builtins/arrays.go)\n- [slices](builtins/slices.go)\n- [maps](builtins/maps.go)\n- [structs](builtins/structs.go)\n- [structs - anonymous](builtins/functions-anonymous.go)\n- [interfaces \u0026 polymorphism](builtins/interfaces-and-polymorphism.go)\n- [pointers](builtins/pointers.go)\n- [functions \u0026 methods](builtins/functions-and-methods.go)\n- [functions - anonymous](builtins/functions-anonymous.go)\n\n### Conditions and loops\n\n- if\n- for\n- [switch](builtins/switch.go)\n\n## TODO\n\n- maybe a go course for beginners in the future? 🤔\n- add more lib/utils\n- add info about primitives, typed/untyped constant, iota\n- add info about aggregated/composite types\n- add info about if, switch, for\n- more io.Writer examples\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffbac%2Fgo-resources","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffbac%2Fgo-resources","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffbac%2Fgo-resources/lists"}