Standard library / reflect
reflect.StructTag.Lookup()
Read a tag value and presence flag; useful when an empty value is meaningful. Malformed tags have unspecified behavior. Expected stdout: '"" true\n'.
Formal Syntax & Structure
go syntaxgo
func (tag StructTag) Lookup(key string) (value string, ok bool)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| key | string | Map key type, or a struct tag key. |
Return Value
(value string, ok bool)
Read a tag value and presence flag; useful when an empty value is meaningful.
Working Example
Example Snippetgo
package main
import ( "fmt" "reflect")
func main() { tag := reflect.StructTag(`json:""`) s, ok := tag.Lookup("json") fmt.Printf("%q %v\n", s, ok)}