User Tools

Site Tools


linux:scribble

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
linux:scribble [2015/11/26 04:40] – how to resize loop-AES partition styblalinux:scribble [2015/11/28 01:54] – add golang and JSON stybla
Line 167: Line 167:
 ''git checkout --track origin/daves_branch'' ''git checkout --track origin/daves_branch''
  
 +
 +===== Go =====
 +
 +Aka golang
 +
 +==== JSON ====
 +
 +Remember that struct attributes/members must begin with capital letter/character. Otherwise you'll get an empty JSON. It took me very long time to figure this one out :-(
 +
 +<file golang json_test.go>
 +package main
 +
 +import (
 +  "encoding/json"
 +  "fmt"
 +)
 +
 +// Attributes, eg. Name, must begin with capital letter/character, otherwise it won't work.
 +// Also, JSON mapping is shown.
 +type Message struct {
 +    Name string `json:"name"`
 +    Body string `json:"body"`
 +    Time int64  `json:"unix_time"`
 +}
 +
 +func main() {
 +  m := Message{"Alice", "Hello", 1294706395881547000}
 +  b, err := json.Marshal(m)
 +  fmt.Println(err)
 +  fmt.Println(string(b))
 +}
 +</file>
  
 ===== iconv ===== ===== iconv =====
linux/scribble.txt · Last modified: 2022/07/06 17:27 by stybla