FAQ
Last updated
Last updated
go-micro service interactions
How to download all dependencies after cloning the repo?
How to use go modules from a Fork and branch
To use a fork, e.g.,
https://github.com/drnic/fatih-color
, and a branchsilly-changes
, You need to updatego.mod
to use the replace helper:
How to update 3rd party dependencies?
How to get commitizen and cz-conventional-changelog work for non-node-git-repo
?
You can get commitizen and cz-conventional-changelog work for non-node-git-repo
with global installation. Here are the steps that I have followed.
How to clean cached go modules?
How to Prepare for a Release?
how to debug in VS Code?
every time, make sure
file with main()
is opened before proceeding to next steps
open GoLang file with main()
method you want to debug.
click on debug icon in Action Bar
click on Launch [▶] button.
Optionally edit .vscode/launch.json
and add args
, env
etc.
How to implement integration tests?
Integration tests are e2e tests that invoke Handler
methods directly and ignore networking completely.
True e2e tests are Black-box tests that invoke network endpoint.
Notice the last test has the convention of:
using Integration
in the test name.
checking if running under -short
flag directive.
Basically, the spec goes:
"write all tests normally. if it is a long-running tests, or an integration test, follow this naming convention and check for
-short
"
When we want to run our unit tests, we would use the -short flag, and omit it for running our integration tests or long running tests.
Use
t.Errorf
t.Logf
for logging. don't uselogrus
or defaultlog
How to ssh and debug a scratch
container?
Ephemeral containers are a great way to debug running pods, as you can’t add regular containers to a pod after creation. These containers executes within the namespace of an existing pod and has access to the file systems of its individual containers.
How to debug a pod
that is crashing during initialization? If you pod
crashing you cannot SSH to it, e.g., to see file system etc. Assuming your container has busybox at /bin/busybox
, add following command
to your deployment yaml.
Then run kubectl exec -it $POD_NAME -- /bin/busybox sh
to SSH to the container.
Why some ORM model fields are pointers?
all fields having a zero value, like 0, '', false or other zero values, won’t be saved into the database but will use its default value. If you want to avoid this, consider using a pointer type or scanner/valuer, e.g:
Note: google wrapper types google.protobuf.StringValue, .BoolValue, .UInt32Value, .FloatValue, etc. map to pointers of the internal type at the ORM level, e.g. string, bool, uint32, float
How to run go-micro
gRPC services and Micro
REST Gateway on k8s?
So you want to use k8s internal CoreDNS
as service registry
?, then you have to follow some rules:
Service name cannot have .
(dot) due to k8s DNS limits, so make it simple via environment variables e.g., MICRO_SERVER_NAME=account
custom build REST Gateway as micro/micro:latest
image is outdated. optionally add CORS plugin.
performance If you’re concerned about performance, try
You can now enable profiling in go-micro by setting MICRO_DEBUG_PROFILE=true This will enable pprof and write a cpu profile and heap profile to /tmp the profiles will be [service name].{cpu, mem}.pprof
How to rollback a git commit?
How to Push Git Tags with Commit? Refer: how-to-push-git-tags-with-commit
How to debug etcd?