tanaike

The Thinker

Updated ggsrun to v141

ggsrun was updated to v.1.4.1 v1.4.1 (February 9, 2018) For uploading, the resumable-upload method was added. The resumable-upload method is automatically used by the size of file. “multipart/form-data” can upload files with the size less than 5 MB. “resumable-upload” can upload files with the size more than 5 MB. The chunk for resumable-upload is 100 MB as the default. Users can also give this chunk size using an option.

Copying Values from JSON to Struct using reflect Package

Gists This is a sample script for copying values from JSON to a struct using reflect package. Script : package main import ( "encoding/json" "fmt" "reflect" ) type obj struct { Key1 string `json:"k1"` Key2 string `json:"k2"` Key3 int64 `json:"k3"` Key4 int `json:"k4"` Key5 bool `json:"k5"` } func main() { data := `{"k1": "v1", "k2": "v2", "k3": 1234567890, "k4": 456, "k5": true}` d := map[string]interface{}{} json.Unmarshal([]byte(data), &d) obj := &obj{} s := reflect.

Parsing JSON object (keys are number and changing every time)

Gists This sample script is for parsing JSON object. In the object, the keys are number and changing every time. Object: { "key1": { "key2": [ {"0": [{"key3": "value3a"}, {"key3": "value3b"}]}, {"1": [{"key3": "value3c"}, {"key3": "value3d"}]} ] } } Script: package main import ( "encoding/json" "fmt" "strconv" ) type key1 struct { Key1 key2 `json:"key1"` } type key2 struct { Key2 []interface{} `json:"key2"` } func main() { data := `{"key1": {"key2": [{"0": [{"key3": "value3a"}, {"key3": "value3b"}]},{"1": [{"key3": "value3c"}, {"key3": "value3d"}]}]}}` k1 := &key1{} json.

Adding a Label to a Message using Message ID for Gmail

Gists These are sample scripts for adding a label to a message using message ID for Gmail. Sample 1 This sample adds a label to a thread using message ID. In this case, all messages in the thread have the label. Even if it adds a label to a message in the thread using addLabel(), all messages in the thread have the label, becauce addLabel can only be used for the thread.