formparser

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

README

简介

这是一个用于将结构体转换为HTTP请求所需要的form表单格式的转换器。支持自定义tag解析。

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolPtr

func BoolPtr(v bool) *bool

func Float64Ptr

func Float64Ptr(v float64) *float64

func Int64Ptr

func Int64Ptr(v int64) *int64

func IntPtr

func IntPtr(v int) *int

func StringPtr

func StringPtr(v string) *string

Types

type FormParser

type FormParser struct {
	// contains filtered or unexported fields
}

FormParser 将结构体对象转换成HTTP请求所需的KV形式, 只处理struct及*struct类型

> 关键字"..." 表示该字段的子字段不继承父辈的标签, 该方式可用于struct,map类型

例如:
type Demo1 struct {
		Auth 		`zwf:"..."`
}

type Demo2 struct {
		Auth		`zwf:"auth"`
}

type Auth struct {
 	AK *string	`zwf:"ak"`
}

Demo1: "ak"="xxx"
Demo2: "auth.ak"="xxx"

> 关键字"join" 可以将[]string进行按英文逗号join操作, 参见parser_test.go的TestParse例子

func Default

func Default() *FormParser

func New added in v0.0.2

func New(tag, ignoreFlag string) *FormParser

func (*FormParser) Debug

func (p *FormParser) Debug(v reflect.Value)

func (*FormParser) ToMap

func (p *FormParser) ToMap(v reflect.Value) (map[string]string, error)

ToMap the param v should be either reflect.ValueOf(struct) or reflect.ValueOf(*struct)

type KV

type KV struct {
	K string
	V string
}

Jump to

Keyboard shortcuts

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