struct_tag

package module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2021 License: MIT Imports: 2 Imported by: 9

README

struct_tag

a multi-line struct tag parser.

Build Status Coverage Status Go Report Card Documentation

Install

$ go get github.com/lovego/struct_tag

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrSyntax = errors.New("invalid syntax")

Functions

func Get

func Get(tag, key string) string
Example
fmt.Println(Get(`a:"av"`, `a`))
Output:

av

func Lookup

func Lookup(tag, key string) (value string, ok bool)
Example (False)
fmt.Println(Lookup(``, ``))
fmt.Println(Lookup(` `, ``))
fmt.Println(Lookup(`a`, ``))
fmt.Println(Lookup(`a:""`, ``))
fmt.Println(Lookup(`a:"av"`, `b`))
Output:

 false
 false
 false
 false
 false
Example (True)
fmt.Println(Lookup(`a:""`, `a`))
fmt.Println(Lookup(`a:"av"`, `a`))
fmt.Println(Lookup(`a:"av" b:"b\" v"`, `b`))
fmt.Println(Lookup(`a:"av"
		b:"b v" `, `b`))
fmt.Println(Lookup(`名称:"值
\"def"`, `名称`))
Output:

 true
av true
b" v true
b v true
值
"def true

func Parse

func Parse(tag string) (result map[string]string)
Example (True)
fmt.Println(Parse(`a:""`))
fmt.Println(Parse(`a:"av"`))
fmt.Println(Parse(`a:"av" b:"b\" v"`))
fmt.Println(Parse(`a:"av"
		b:"b v" `))
fmt.Println(Parse(`名称:"值
\"def"`))
Output:

map[a:]
map[a:av]
map[a:av b:b" v]
map[a:av b:b v]
map[名称:值
"def]

func Unquote

func Unquote(s string) (string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL