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
+4.6k JavaScript : Rounding number to decimal formats to display currency
+36k Golang : Get file last modified date and time
+11.5k CodeIgniter : Import Linkedin data
+87.8k Golang : How to convert character to ASCII and back
+9.4k Golang : How to protect your source code from client, hosting company or hacker?
+9.4k Golang : Timeout example
+10.1k Golang : Test a slice of integers for odd and even numbers
+27.5k Golang : dial tcp: too many colons in address
+15.9k Golang : Update database with GORM example
+5.5k Golang : Stop goroutine without channel