github.com/sandwich-go/boost@v1.3.29/misc/annotation/README.md (about) 1 # annotation 2 3 注释解析器 4 5 # 格式 6 ```text 7 // {$MagicPrefix}{$Name}({$Key0}={$Value0}, {$Key1}={$Value1}, {$Key2}="{$Value2}" ...) 8 ``` 9 10 **注意** : 11 - 字符串类型值需要使用 `""` 12 - `$MagicPrefix` 默认为 `annotation@` 13 14 # 例子 15 ```text 16 // annotation@A( AK=127, AV="AAAAA" ) 17 ``` 18 19 解析 : 20 ```go 21 line := `// annotation@A( AK=127, AV="AAAAA" )` 22 ann, err0 := Default.Resolve(line) 23 xpanic.WhenError(err0) 24 fmt.Println("Name:", ann.Name()) 25 fmt.Println("Line:", ann.Line()) 26 akVal, err1 := ann.Int("AK") 27 xpanic.WhenError(err1) 28 fmt.Println("AK:", akVal) 29 fmt.Println("AV:", ann.String("AV")) 30 ``` 31 32 Output: 33 ```text 34 Name: a 35 Line: // annotation@A( AK=127, AV="AAAAA" ) 36 AK: 127 37 AV: AAAAA 38 ```