Source: lifesavvy.com


var slice []string
b, _ := json.Marshal(slice)
fmt.Println(string(b)) // Output: null
var slice []string
slice = make([]string, 0)
b, _ := json.Marshal(slice)
fmt.Println(string(b)) // Output: []
var slice []string
slice = make([]string, 0)
fmt.Println(len(slice)) // Output: 0

slice = append(slice, "some-string")
fmt.Println(len(slice)) // Output: 1

b, _ := json.Marshal(slice)
fmt.Println(string(b)) // Output: ["some-string"]

  1. Free text/grammar: literally what you type
  2. Lexer/lexical analysis: text to tokens
  3. Tokens/Lexemes: chunks of your syntax
  4. Parser: tokens to the syntax tree
  5. Syntax Tree/Abstract Syntax Tree or AST: model represented operator with its precedence level and associativity
  6. Evaluator: running through AST and execute the operation.


SELECT 'Anto' as name, 12 as age
UNION SELECT 'Linda', 9
UNION SELECT 'Mike', 10
SELECT  *
FROM (values ('Anto', 12),('Linda', 9), ('Mike', 10) ) AS q (name, age)
SELECT id FROM regexp_split_to_table('1,2,3,4,5,7,8,9', ',') AS id
SELECT 1 as id, pg_sleep(10)


  1. Go to System Preference > Java
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
$ echo "export JAVA_HOME=/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home" >> ~/.bash_profile
$ source .bash_profile
$ java -version



3.times do
# something
end
s = '{"hello": "world"}'

# Wrong
# Output => "\"{\\\"hello\\\": \\\"world\\\"}\""
s.to_json

# Right
# Output => {"hello"=>"world"}
JSON.parse(s)

m = {hello: 'world'}

# Right
# Output => "{\"hello\":\"world\"}"
m.to_json

Failure/Error: request_body = Mustache.render(body,data)

Errno::ENOENT:
No such file or directory - ./mustache.mustache
request_body = Mustache.render(JSON.generate(body),data)

Iman Tung

Technology to write, life to grateful. Overthinking is good, only if it has the output. Fundamental is the main concern.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store