Tag Archives: golang
Golang’s sync.Map internals
Great article on the topic — https://victoriametrics.com/blog/go-sync-map/index.html. The whole series of articles is solid, so please take a look if you are interested. Let me share the most important insights. How it works Internal structure is:
1 2 3 4 5 6 |
type Map struct { mu Mutex read atomic.Pointer[readOnly] dirty map[any]*entry misses int } |
Go memory hints
Below hints are related to very hot places of CPU/memory bound programs. And in regular (i/o bound) programs do not make much sense. Stack vs heap Go’s compiler goal is to allocate on the stack as much as possible. As it will reduce the amount of data that needs to be cleaned by the Garbage …
Set github actions for you repo
If you want to run tests/linters against you golang project, place something like the example below in .github/workflows/somename.yml to your project:
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 31 32 |
name: ci-cd on: push: branches: - '**' env: GONOSUMDB: "github.com/<your-organization>" GOPRIVATE: "github.com/<your-organization>" jobs: ci-cd: strategy: matrix: go-version: [ 1.16.x ] runs-on: ubuntu-latest steps: - name: Install Go uses: actions/setup-go@v2 with: go-version: ${{ matrix.go-version }} - name: Write .netrc for private go modules env: NETRC_USER: ${{ secrets.NETRC_USER }} NETRC_PASS: ${{ secrets.NETRC_PASS }} run: echo "machine github.com login ${{ secrets.NETRC_USER }} password ${{ secrets.NETRC_PASS }}" > $HOME/.netrc - name: Checkout the code uses: actions/checkout@master with: fetch-depth: 1 - name: Run Makefile::ci-cd-check run: make ci-cd-check |
Good article on that — https://github.com/mvdan/github-actions-golang
Go internals
Channels https://youtu.be/KBZlN0izeiY Go scheduler https://youtu.be/YHRO5WQGh0k