package main
import "fmt"
import "reflect"
type myStruct struct {
string1 []byte
string2 []byte
}
func main() {
v := myStruct{[]byte("text"), []byte("text2")}
fmt.Println(getField(&v, "string1"))
}
func getField(v *myStruct, field string) string {
r := reflect.ValueOf(v)
f := reflect.Indirect(r).FieldByName(field)
return string(f.Bytes())
}