xsd

package module
v0.0.0-...-30e5405 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2020 License: MIT Imports: 4 Imported by: 10

README

go-xsd-types

XML Schema Definition Primitive Types for GO

Example

type MyStruct struct {
	Duration *Duration `xml:"duration,attr"`
	DateTime *DateTime `xml:"dateTime,attr"`
}

val := MyStruct{}

err := xml.Unmarshal([]byte(`<node
 duration="PT1S"
 dateTime="2015-09-07T05:45:54">
</node>`), &val)

fmt.Println(val.Duration, val.DateTime)

Documentation

Index

Constants

View Source
const (
	DateTimeFormat     = "2006-01-02T15:04:05.999999999-07:00"
	DateTimeNoTimezone = "2006-01-02T15:04:05.999999999"
	DateTimeUTC        = "2006-01-02T15:04:05.999999999Z"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DateTime

type DateTime time.Time

func DateTimeFromString

func DateTimeFromString(str string) (*DateTime, error)

func (*DateTime) MarshalXMLAttr

func (dt *DateTime) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

func (*DateTime) String

func (dt *DateTime) String() string

func (*DateTime) UnmarshalXMLAttr

func (dt *DateTime) UnmarshalXMLAttr(attr xml.Attr) error

type Duration

type Duration struct {
	Years       int64
	Months      int64
	Days        int64
	Hours       int64
	Minutes     int64
	Seconds     int64
	Nanoseconds int64
	Negative    bool
}

func DurationFromString

func DurationFromString(str string) (*Duration, error)

BenchmarkDurationFromString-8 5000000 241 ns/op BenchmarkDurationFromStringRegex-8 1000000 1924 ns/op

func (*Duration) MarshalXMLAttr

func (d *Duration) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

func (Duration) String

func (d Duration) String() string

func (*Duration) ToNanoseconds

func (d *Duration) ToNanoseconds() (int64, error)

func (*Duration) ToSeconds

func (d *Duration) ToSeconds() (float64, error)

func (*Duration) UnmarshalXMLAttr

func (d *Duration) UnmarshalXMLAttr(attr xml.Attr) error

Jump to

Keyboard shortcuts

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