Skip to content
This repository has been archived by the owner on Oct 11, 2018. It is now read-only.

Add structs.Names() method #26

Closed
fatih opened this issue Apr 18, 2015 · 0 comments
Closed

Add structs.Names() method #26

fatih opened this issue Apr 18, 2015 · 0 comments

Comments

@fatih
Copy link
Owner

fatih commented Apr 18, 2015

Just to return the names of each struct field. It'll be handy to use in a for range:

type Server struct {
    Name     string
    Number   int
    Disabled bool
}

s := new(Server)
for _, name := range structs.Names(s) {
    // prints: "Name", "Number" and "Disabled"
    fmt.Println(name)
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant