Tickers I was looking into timers and I came across tickers. Basically they allow you to trigger an event at a regular time interval. One simple example could be some kind of monitoring. What’s interesting is that it pushes a Ticker to a channel. Here is a basic example: package main import ( "fmt" "os" "sync" "time" ) func checkInBackground(ticker time.Ticker, wg *sync.WaitGroup) { wg.Add(1) for ; true; <-ticker.C { fmt....

August 30, 2021 · 1 min · Nolan

Limit number of concurrent requests  [draft]

Limiting the number of concurrent http requests I was looking to use gorountine in the context of http requests. More specifically, how to limit the number of concurrent of http call made to a service. Let’s say you are making call to an API that is rate limited.

August 29, 2021 · 1 min · Nolan

Check for misspelled words

Checking for typos & misspell words I came across that project client9/misspell on github that aims to: “Correct commonly misspelled English words… quickly.” So I decided to try it directly for that blog by using a github action. Implementation Github action: name: Go on: [push, pull_request] jobs: build: name: Check for misspell runs-on: ubuntu-latest container: golang:1.15-buster steps: - uses: actions/checkout@v2 - run: |GO111MODULE=on go get -u github.com/client9/misspell/cmd/misspell@v0.3.4 misspell -error misspell blog/content/posts/*....

April 27, 2021 · 1 min · Nolan


Getting dependencies via GOPROXY I recently wanted to use a private registry in a go project. It can be for many reasons: ensure immutability from one built to another ensure avaibility of a build (remember npm author who removed his library and broke half the internet?) get non-public library How it works Quick & Easy It is super easy you just have to add an env variable: export GOPROXY="myprivateserver....

April 19, 2021 · 1 min · Nolan

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....

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.jarENTRYPOINT [ "java", \ "-javaagent:dd-java-agent.jar", \ "-jar", "app....

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....

April 5, 2021 · 2 min · Nolan

Check broken links in Markdown

Broken links It’s always frustrating to follow a dead link, so I would like to avoid that on my blog. I’ve found couple of projects that could help: https://github.com/raviqqe/muffet https://github.com/linkchecker/linkchecker https://github.com/stevenvachon/broken-link-checker These projects looks to be a good fit, however I would have adapt the CI part. If not I would be checking my current online version and not the latest changes, one idea could be to spin up a local web server and test again it....

April 4, 2021 · 1 min · Nolan

Pandas meets SQL

Pysql I was exploring data from a CSV, I used Jupyter notebook as I’m a bit familiar with it and it’s a great fit for this kind of use case. It’s very easy to load data in a dataframe, however I don’t use pandas often enough and cannot remember all the functions. I just wanted to write SQL queries from the dataframe itself. import matplotlib.pyplot import pandas as pd from pandasql import sqldf df = pd....

March 3, 2021 · 1 min · Nolan