Golang go/ast.Ident.IsExported() function example
package go/ast
IsExported reports whether id is an exported Go symbol (that is, whether it begins with an uppercase letter).
Golang go/ast.Ident.IsExported() function usage example
func inspectFieldTag(f *File, node ast.Node) {
field := node.(*ast.Field)
if field.Tag == nil {
fmt.Println("Field tag empty")
return
}
if len(field.Names) == 0 {
fmt.Println("Field tag name empty")
return
}
if field.Names[0].IsExported() { // <-- here
fmt.Println("Field tag id is exported Go symbol")
return
}
}
Reference :
Advertisement
Something interesting
Tutorials
+5.4k Golang : Return multiple values from function
+10.3k Golang : Wait and sync.WaitGroup example
+12.1k Golang : md5 hash of a string
+14.8k Golang : Get URI segments by number and assign as variable example
+12.3k Golang : Display list of countries and ISO codes
+11.5k Golang : Format numbers to nearest thousands such as kilos millions billions and trillions
+11.2k Golang : Fix - does not implement sort.Interface (missing Len method)
+6.3k Javascript : Generate random key with specific length
+11.6k Golang : Convert(cast) float to int
+11.8k Golang : GTK Input dialog box examples
+5.5k Golang : If else example and common mistake
+10.5k Generate Random number with math/rand in Go