Skip to content

Latest commit

 

History

History
27 lines (20 loc) · 525 Bytes

README.md

File metadata and controls

27 lines (20 loc) · 525 Bytes

gostruct

A go tool to set/get struct fields value from expression string which similar jsonpath.

#Example

Get

Get value from struct using expression

    Expression:
    
    City[0].Park.Address
    City[0].Park.Name
    Emails[0]
    
    Get Sample:
    field, err := GetField(s, `City[0].Park.Maps`)
    field, err = GetField(s, "Emails[0]")

Set

	err := SetField(s, "Person.Streat", "hello ST")
	err := SetField(s, `Maps["lix"]`, "wangzai")
	err := SetField(s, "Emails[0]", "[email protected]")