How to work with core dumps of Go programs
If you want to check what is going on in your service during load (on production or during stress testing process), you can take a core dump of your app and load it into Goland for further debugging.
1 2 3 4 5 6 |
# first you need to get your app's PID ps aux|grep <your-app-bin-name> gcore <PID> # download dump file and binary file to a local machine with kubectl cp <some-namespace>/<some-pod>:/core.<PID> ~/Downloads kubectl cp <some-namespace>/<some-pod>:<your-app-bin-path> ~/Downloads |
Then open it your Goland: Navigate to Run | Open Core Dump. In the Executable field, …
Nice introductory article on why Golang is not OOP
It is a copy of this article — https://rakyll.org/typesystem/ It is real struggle to work with a new language, especially if the type doesn’t resemble what you have previously seen. I have been there with Go and lost my interest in the language when it first came out due to the reason I was pretending …
How to install linux mint on hp
I’ve run into a problem — had a lot of error logging saying «PCIe Bus Error: severity=Corrected, type=Physical Layer», «AER Corrected error received», and similar. The problem is that it fills all the log space and the installation process cannot finish. You can run into it on HP laptops on monoblocks. What you can do.
How to watch tv on amazon Fire TV stick
You need to install some apps for that. Settings→My Fire TV→Developer options→Apps from Unknown Sources→ON. 🔍→Type «Downloader»→Click on it→Install. Home→Downloader→Type following link (https://smarttvnews.ru/wp-content/uploads/2017/03/LazyIPTV_2.44.apk)→Install. 🔍→Type «VLC Player»→Install. Home→Lazy IPTV→New playlist→From Internet(by url)→Type «https://smarttvnews.ru/apps/iptvchannels.m3u». Now you can watch it. Home→Lazy IPTV→Channel search→Select a channel you want. More on apps and playlists here — https://smarttvnews.ru/kak-besplatno-smotret-tv-kanalyi-na-android-ustroystvah-i-gde-skachat-besplatnyie-iptv-pleylistyi/ (in Russian).
Clean architecture pattern
The main idea is to have layers that only depend on inner layers (see images below). Let’s imagine you have a repository that includes several applications. Layers Domain (Entities) Has basic types and interfaces for your application. As well as common logic for your domain. Usecase Services, handlers, controllers, whatever we call them. Adapters Implementations …
A way to test http client in go
A couple of ways are described here — http://hassansin.github.io/Unit-Testing-http-client-in-Go The way I liked is the following one:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
func Test_Mine(t *testing.T) { ... client := httpClientWithRoundTripper(http.StatusOK, "OK") ... } type roundTripFunc func(req *http.Request) *http.Response func (f roundTripFunc) RoundTrip(req *http.Request) (*http.Response, error) { return f(req), nil } func httpClientWithRoundTripper(statusCode int, response string) *http.Client { return &http.Client{ Transport: roundTripFunc(func(req *http.Request) *http.Response { return &http.Response{ StatusCode: statusCode, Body: ioutil.NopCloser(bytes.NewBufferString(response)), } }), } } |
Go internals
Channels https://youtu.be/KBZlN0izeiY Go scheduler https://youtu.be/YHRO5WQGh0k
Setup local Athens for proper go mod
There is a project called Athens for proxying all your go mod downloads. How to use it locally. 1. Create the following files and directories: a. /Users/d.bolgov/.ssh-athens/storage — empty directory to cache go modules b. /Users/d.bolgov/.ssh-athens/.netrc — if you prefer using .netrc
1 2 3 |
machine github.com login [yourlogin] password [yourpassword] |
c. /Users/d.bolgov/.ssh-athens/gitconfig/.gitconfig — if you want to substitue some urls. I personally …
Port forwarding with kubectl
If you want some kubernetes pod to forward all the traffic to you local machine, you can do this: 1. get pod id with
1 |
kubectl --kubeconfig <config> get po -lapp=<pod_label_app> -Lversion,cfg,infra-cfg |
2. forward exact port from it to you localhost with
1 |
kubectl --kubeconfig <config> port-forward <pod-id> localhost_port:pod_port |
And you can request you localhost to reach pod on selected port.
Installing protobuf tools on MacOS
Installing protoc
1 |
brew install protobuf |
Or follow different instructions. Installing grpc_cli Option 1. Easy way.
1 2 |
brew tap grpc/grpc brew install --with-plugins grpc |
It is described here — https://github.com/grpc/homebrew-grpc. Option 2. Hard way — using cmake and make. NOT RECOMMENDED.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
brew install autoconf automake libtool shtool cmake git clone -b $(curl -L https://grpc.io/release) https://github.com/grpc/grpc cd grpc git submodule update --init mkdir -p cmake/build cd cmake/build cmake ../.. make gRPC_INSTALL=ON make install # and continue accordgin to https://github.com/grpc/grpc/blob/master/BUILDING.md |
Or follow these instructions