Skip to content

alileza/structs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Structs GoDoc CircleCI Coverage Status

This library helps you to play around with structs, such as bind incoming request into struct, validate struct, etc.

import "github.com/alileza/structs"

func main(){
    // Bind request value into struct
    err := structs.BindRequest(httpRequest, &target)
    
    // Validate struct value
    err := structs.ValidateStruct(&MyStruct)
    
    // Convert struct to map
    MyMap := structs.ToMap(MyStruct)
    
    // Copy struct/slice value to another
    err := structs.Copy(MyStruct, &MyOtherStruct)
}

Bind Request

BindRequest will scan your struct and bind the request Values / Body into your struct according to json tag on struct.

Example Here

Validate Struct

ValidateStruct will validate struct if required tag is equal to true.

Example Here

To Map

ToMap returns map following the input struct.

Example Here

Copy

Copy struct/slice/etc value to another

About

Go Libraries that helps to play around with structs

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages