Skip to content

A go tool to set/get struct fields value from expression string

License

Notifications You must be signed in to change notification settings

lixingwang/gostruct

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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]")

About

A go tool to set/get struct fields value from expression string

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages