reflect.String() Function in Golang with Examples Last Updated : 05 May, 2020 Comments Improve Suggest changes Like Article Like Report Go language provides inbuilt support implementation of run-time reflection and allowing a program to manipulate objects with arbitrary types with the help of reflect package. The reflect.String() Function in Golang is used to get the string v's underlying value, as a string. To access this function, one needs to imports the reflect package in the program. Syntax: func (v Value) String() string Parameters: This function does not accept any parameter. Return Value: This function returns the string v's underlying value, as a string. Below examples illustrate the use of the above method in Golang: Example 1: C // Golang program to illustrate // reflect.String() Function package main import ( "fmt" "reflect" ) // Main function func main() { var k = reflect.TypeOf(0) var e = reflect.TypeOf("") //use of String method fmt.Println(reflect.FuncOf([]reflect.Type{k}, []reflect.Type{e}, false).String()) } Output: func(int) string Example 2: C // Golang program to illustrate // reflect.String() Function package main import ( "fmt" "reflect" ) type Struct1 struct { Var1 string Var2 string Var3 float64 Var4 float64 } // Main function func main() { NewMap := make(map[string]*Struct1) NewMap["abc"] = &Struct1{"abc", "def", 1.0, 2.0} subvalMetric := "Var1" for _, Value:= range NewMap { s := reflect.ValueOf(&Value).Elem() // use of String() method println(s.String()) println(s.Elem().String()) metric := s.Elem().FieldByName(subvalMetric).Interface() fmt.Println(metric) } } Output: <*main.Struct1 Value> <main.Struct1 Value> abc Comment More infoAdvertise with us Next Article reflect.String() Function in Golang with Examples S SHUBHAMSINGH10 Follow Improve Article Tags : Go Language Golang-reflect Similar Reads strings.Replace() Function in Golang With Examples strings.Replace() Function in Golang is used to return a copy of the given string with the first n non-overlapping instances of old replaced by new one. Syntax: func Replace(s, old, new string, n int) string Here, s is the original or given string, old is the string that you want to replace. new is 2 min read reflect.TrySend() Function in Golang with Examples Go language provides inbuilt support implementation of run-time reflection and allowing a program to manipulate objects with arbitrary types with the help of reflect package. The reflect.TrySend() Function in Golang attempts to send x on the channel v but will not block. To access this function, one 2 min read reflect.StructOf() Function in Golang with Examples Go language provides inbuilt support implementation of run-time reflection and allowing a program to manipulate objects with arbitrary types with the help of reflect package. The reflect.StructOf() Function in Golang is used to get the struct type containing fields. To access this function, one need 2 min read reflect.Type() Function in Golang with Examples Go language provides inbuilt support implementation of run-time reflection and allowing a program to manipulate objects with arbitrary types with the help of reflect package. The reflect.Type() Function in Golang is used to get v's type. To access this function, one needs to imports the reflect pack 1 min read reflect.Tag.Get() Function in Golang with Examples Go language provides inbuilt support implementation of run-time reflection and allowing a program to manipulate objects with arbitrary types with the help of reflect package. The reflect.Tag.Get() Function in Golang is used to find the value associated with key in the tag string, an empty string is 2 min read reflect.SliceOf() Function in Golang with Examples Go language provides inbuilt support implementation of run-time reflection and allowing a program to manipulate objects with arbitrary types with the help of reflect package. The reflect.SliceOf() Function in Golang is used to get the slice type with element type t, i.e., if t represents int, SliceO 1 min read reflect.SetBool() Function in Golang with Examples Go language provides inbuilt support implementation of run-time reflection and allowing a program to manipulate objects with arbitrary types with the help of reflect package. The reflect.SetBool() Function in Golang is used to sets v's underlying value. To access this function, one needs to imports 2 min read strings.SplitN() Function in Golang with Examples strings.SplitN() Function() is a string manipulation function in Go language. It is used to split a given string into substrings separated by a separator. This function returns the slices of all substrings between those separators. Syntax: func SplitN(s, sep string, n int) []string Here, s is the st 3 min read strings.IndexFunc() Function in Golang With Examples strings.IndexFunc() Function in Golang is used to returns the index into s of the first Unicode code point satisfying f(c), or -1 if none do. Syntax: func IndexFunc(str string, f func(rune) bool) int Here, str is string which may contain Unicode code point and f is func which validates the Unicode p 1 min read strings.NewReplacer() Function in Golang With Examples strings.NewReplacer() Function in Golang returns a new Replacer from a list of previous, new string sets. Substitutions are performed within the order they show up within the target string, without overlapping matches. The old string comparisons are done in argument order. The old string comparisons 1 min read Like