Golang code coverage badge in gitlab

Adding Golang code coverage badge in gitlab Currently there is no example in gitlab official documentation regarding code coverage for golang. However I found: https://medium.com/@ulm0_/golang-multi-packages-test-coverage-with-gitlab-ci-a7b52b91ef34 https://github.com/t-yuki/gocover-cobertura So I tried them out and it looks to work fine. Live Example I quickly made a test repo: https://gitlab.com/emirot.nolan/go-test-coverage/ To try that out and it work fine ! Here is the gitlab-ci.yml stages: - coveragetest test: stage: coveragetest image: golang script: - go get github.com/t-yuki/gocover-cobertura - go test ./... -v -coverprofile coverage.txt - gocover-cobertura < coverage.txt > coverage.xml coverage: /^coverage:\s(\d+(?:\.\d+)?%)/ artifacts: name: $CI_JOB_NAME/coverage.txt paths: - coverage.xml expire_in: 2 days reports: cobertura: coverage.xml Then in order to get the coverage badge it can be added in the readme or in the repo settings>general>badges. ...

April 16, 2021 · 1 min · Nolan

Monitoring golang web app with Datadog

Monitoring golang web application with Datadog Adding datdog monitoring for java was a matter of minutes, so I thought for golang it would be even faster. Get the datadog jar add it the the dockerfile entrypoint and that’s it. (assuming datadog env variables are set up correctly in k8s) It will be something like: RUN curl --retry 3 --connect-timeout 3 -Ss -o dd-java-agent.jar https://github.com/DataDog/dd-trace-java/releases/download/v0.78.1/dd-java-agent.jar ENTRYPOINT [ "java", \ "-javaagent:dd-java-agent.jar", \ "-jar", "app.jar", ] And it worked, let’s look into it for golang. ...

April 15, 2021 · 2 min · Nolan

First golang project

Import Function form package I thought it was going to be similar to many languages and I will just have to just do something like: import "mypakckage/Myfuction" Well… no, first it will depend on your GOPATH, which is handled differently depending of your go version. Secondly, In golang exported function must be in Uppercase, otherwise it won’t compile! First module So I chose the easiest that I could find first to structure project by creating a module. ...

April 9, 2021 · 1 min · Nolan

First few lines in golang

Intro I’ve been casually looking into the go language without trying it much. Now it’s time to write so go code :) Golang Looping First discovery there is no while keyword in golang, I was pretty surprised I thought I was missing something. I then look in the spec and there is only for. I like that they only have limited number of keywords. i := 0 for i < 10 { fmt.Println(i) } Return statements Return statement can be specified in function definition E.g: ...

April 5, 2021 · 2 min · Nolan