GO Lang is the new language from google

http://golang.org

EXPORTED IDENTIFIERS

Declare variable in struct prefixing lowercase.

Found Json.Marshel isn't working when we define a variable in struct starting with lower case. 

Check out this code.

package main

import (
"encoding/json"
"fmt"
"os"
)

func main() {

type MilvariableStartswithUpperCase struct {
  Idint64`json:"id"` //sss
Cty string `json:"firstname"`
}

type MilvariableStartswithLowerCase struct {
id int64
cty string
}

upperCase := MilvariableStartswithUpperCase{1, "UpperCase"}
lowerCase := MilvariableStartswithLowerCase{1, "Lowercase"}

marshalsucessfull, err := json.Marshal(upperCase)
if err != nil {
fmt.Println("error:", err)
}

marshalunsucessfull, err := json.Marshal(lowerCase)
if err != nil {
fmt.Println("error:", err)
}

fmt.Println("----")
fmt.Println("Marshal Sucess")
os.Stdout.Write(marshalsucessfull)
fmt.Println()
fmt.Println("Marshal Failed.")
os.Stdout.Write(marshalunsucessfull)

}

Reason is :

Exported struct field becomes a member of the object. Non-exported fields do not.

http://golang.org/ref/spec#Exported_identifiers

EXPORTED IDENTIFIERS

An identifier may be exported to permit access to it from another package. An identifier is exported if both:

  1. the first character of the identifier's name is a Unicode upper case letter (Unicode class "Lu"); and
  2. the identifier is declared in the package block or it is a field name or method name.

All other identifiers are not exported.