Browse latst posts in Golang Category
"How to unit test" is a very broad question since it depends on what you want to test. In your examp...
How to check for an empty struct?
You can't really override methods in golang as per this answer. However, as you point out you can ha...
goinstall is now history goinstall was replaced by go get. go get is used to manage external / 3rd party libraries (e.g. to download them, update them, install them etc). Type go help get to see com...
You cannot, at least not in Go 1.12.7. Go's Protobuf compiler adds 3 extra fields to each struct gen...
Try primitive.NewObjectIDFromTimestamp. From there you can convert time.Time to primitive.ObjectID a...
Often times you need to retrieve the name of the function that was called and being executed from within that function. You may use this keyword to find it out.
Below is an example of JWT decoding and verification. It uses both the jwt-go and jwk packages: package main import ( "errors" "fmt" "github.com/dgrijalva/jwt-go" "github.com/lestrr...
The OP's comment on the question states that type of getUsersAppInfo is []map[string]interface{}. Lo...
Redis documentation does not support a command like "HMSETEX". "HMSET" modifies the hashkeys and not...
If the map value can be any type, then use reflect to iterate through the map: if v.Kind() == reflec...
Not with plain database/sql but there is an extension library called sqlx that builds on top of data...
RLIMIT_DATA describes the maximum size of a processes data segment. Traditionally, programs that all...
You should be able to do c.Request.URL.Query() which will return a Values which is a map[string][]st...
declare a variable at the top level - outside of any functions: var Global = "myvalue" func InitApp(...
Most Go tools operate on packages, because a package itself forms a unit that may be useful in its e...
Unmarshal the JSON to []interface{} and insert the result in the database. Assuming that c is an mgo...
You can get the token header with c.Request.Header["Token"]. Here is a sample code. package main imp...
If you know that's your data structure, there's no reason to use reflection at all. Just use a type...
This is possible using encoding/json: when calling json.Unmarshal, you do not need to give it an emp...