My first go program
Maximilian Wurzer
Advisory IT Architect, IBM Deutschland
Maximilian Wurzer
Advisory IT Architect, IBM Deutschland
struct User with the fields
uint32)string)string)bool)id ← 1name and surname ← add your namegopher ← obviously, trueGo comes with a sort interface which can be adapted
Len, Less, and Swap
type Interface interface {
// Len is the number of elements in the collection.
Len() int
// Less reports whether the element with index i
// must sort before the element with index j.
Less(i, j int) bool
// Swap swaps the elements with indexes i and j.
Swap(i, j int)
}
Create a type which implements the sort.Interface based on a User slice
Sort the users by ID
struct User with the fields (capital letters are important)
uint32)string)string)bool)b, err := json.Marshal(m)
ID, Name and Surname)var m User
err := json.Unmarshal(b, &m)
and print the Name
Maximilian Wurzer
Advisory IT Architect, IBM Deutschland