{"id":15034868,"url":"https://github.com/matrixai/golang-demo","last_synced_at":"2025-04-09T22:52:31.856Z","repository":{"id":57516919,"uuid":"122317302","full_name":"MatrixAI/Golang-Demo","owner":"MatrixAI","description":"Golang Demo Project","archived":false,"fork":false,"pushed_at":"2020-01-03T07:23:58.000Z","size":34,"stargazers_count":18,"open_issues_count":0,"forks_count":4,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-09T22:52:25.525Z","etag":null,"topics":["golang","golang-examples","golang-package"],"latest_commit_sha":null,"homepage":"https://matrix.ai","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MatrixAI.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":"2018-02-21T09:40:27.000Z","updated_at":"2024-06-17T21:56:26.000Z","dependencies_parsed_at":"2022-09-15T21:50:51.222Z","dependency_job_id":null,"html_url":"https://github.com/MatrixAI/Golang-Demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatrixAI%2FGolang-Demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatrixAI%2FGolang-Demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatrixAI%2FGolang-Demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatrixAI%2FGolang-Demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MatrixAI","download_url":"https://codeload.github.com/MatrixAI/Golang-Demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248125641,"owners_count":21051766,"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":["golang","golang-examples","golang-package"],"created_at":"2024-09-24T20:26:36.928Z","updated_at":"2025-04-09T22:52:31.832Z","avatar_url":"https://github.com/MatrixAI.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Golang Demo\n\nThis is an example Golang project using Nix to setup a development environment.\n\nThis relies on using Go 1.11 or above, as we don't use `GOPATH` global workspace style. Instead this is project based as that fits into Nix better. However a shared global workspace is mediated via the Nix system instead.\n\nNote that the default `$GOPATH` and `$GOCACHE` is `~/go` and `~/.cache/go-build` respectively. However when entering the `nix-shell`, the `$GOPATH` will be set to `./.go`, this is to prevent other projects causing side effects to the `$GOPATH`. We don't trust the `$GOPATH` for sharing unlike the `/nix/store`.\n\nWe have already started a Golang project here by running:\n\n```sh\ngo mod init github.com/MatrixAI/Golang-Demo\n```\n\nA Golang module is basically a \"package\" meaning a bundle of namespaced code. A golang package is basically a \"module\" meaning an importable namespaced code. The Golang module name is usually a DNS address that points to version controlled repository because Golang does not have a dedicated package registry. That is, Golang uses the DNS system as its package registry. However you can actually give it any module name, it just won't be downloadable by any Golang package manager. This module is named: `github.com/MatrixAI/Golang-Demo`.\n\nYou may wonder whey we cannot just use `buildInputs` like other language environments in Nix. This is because Golang dependencies is the Go source code, not the compiled outputs such as the executables, static objects or shared objects. This means adding a Go package to the `buildInputs` will most likely only bring in the compiled executables if it has any and nothing else (becuase by default Go will not produce static or shard objects). This means Golang dependencies is closer to something you combine with your `src`. \n\n## Installation\n\nBuilding the package (as a library):\n\n```sh\nnix-build -E '(import ./pkgs.nix).callPackage ./default.nix {}'\n```\n\nBuilding the releases:\n\n```sh\nnix-build ./release.nix --attr application\nnix-build ./release.nix --attr docker\n```\n\nInstall into Nix user profile:\n\n```sh\nnix-env -f ./release.nix --install --attr application\n```\n\nInstall into Docker:\n\n```sh\ndocker load --input \"$(nix-build ./release.nix --attr docker)\"\n```\n\n## Development\n\nIf your names change or whatever reason, whether it is your own module name, or one of your dependency's name, you will need to change the import paths in all of your source code. To do this easily, you can use the `govers` tool:\n\n```sh\ngovers -d -m 'github.com/MatrixAI/Golang-Demo' 'gitlab.com/MatrixAI/Golang-Demo'\n```\n\nThere are more Golang module commands:\n\n```sh\ngo help mod\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatrixai%2Fgolang-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatrixai%2Fgolang-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatrixai%2Fgolang-demo/lists"}