Walk provides an easy and type safe way to manipulate all fields of the same type of a variable in Go (Golang). Look at the How to use walk.
The easiest way to get walk is go getting it
go get github.com/fvosberg/walk
To manipulate all strings in a given variable you can use the following code
u := User{
FirstName: "*** Random ***",
LastName: "*** Guy ***",
Email: "[email protected]",
}
walk.Strings(u, func(s string) string {
return strings.Trim(s, " *")
})
fmt.Printf("After processing: %#v")
// User{FirstName:"Random", LastName:"Guy", Email:"[email protected]"}