metaleap / go-xsd

[stable since 2013] a lib for loading XML Schema Definition (XSD) files ➜ plus, a tool `makepkg` to code-generate from any *.xsd your Go package with all needed `struct`s to readily `xml.Unmarshal()` documents into, based on the XSD's schema definitions. NOT REALLY MAINTAINED FOR YEARS NOW: try the forks if running into issues.
http://www.reddit.com/r/golang/comments/12g6sl/is_there_a_tool_that_generates_go_source_code_for/
MIT License
216 stars 66 forks source link

Idiot-proof how to install and use go-xsd #22

Closed uccmen closed 7 years ago

uccmen commented 8 years ago

Being an idiot - I still have absolutely no idea on how to use this tool after reading the README. As the title says it - may I suggest an idiot-proof guide on how to install and use this package for all idiots out there like me. It could be a step by step guide for instance.

For example;

  1. go get github.com/metaleap/go-xsd
  2. ...

Much thanks!

zevdg commented 7 years ago

+1 on improving the readme, but FYI the command you're looking for is

go get -u github.com/metaleap/go-xsd/xsd-makepkg

prestonvanloon commented 7 years ago

So how do you use this?

prestonvanloon commented 7 years ago

Ran: xsd-makepkg service.xsd

2017/05/18 18:57:16 LOAD:   www.w3.org/2001/xml.xsd
2017/05/18 18:57:16 MKPKG:  /home/preston/go/src/github.com/metaleap/go-xsd-pkg/www.w3.org/2001/xml.xsd_go/xml.xsd.go
2017/05/18 18:57:16 GOINST: exec: "go-buildrun": executable file not found in $PATH
2017/05/18 18:57:16 LOAD:   www.w3.org/2001/03/xml.xsd
2017/05/18 18:57:16 MKPKG:  /home/preston/go/src/github.com/metaleap/go-xsd-pkg/www.w3.org/2001/03/xml.xsd_go/xml.xsd.go
2017/05/18 18:57:16 GOINST: exec: "go-buildrun": executable file not found in $PATH
2017/05/18 18:57:16 LOAD:   www.w3.org/TR/2002/WD-SVG11-20020108/xml.xsd
2017/05/18 18:57:16 MKPKG:  /home/preston/go/src/github.com/metaleap/go-xsd-pkg/www.w3.org/TR/2002/WD-SVG11-20020108/xml.xsd_go/xml.xsd.go
2017/05/18 18:57:16 GOINST: exec: "go-buildrun": executable file not found in $PATH
2017/05/18 18:57:16 LOAD:   www.w3.org/TR/2002/WD-SVG11-20020108/xlink.xsd
2017/05/18 18:57:16 MKPKG:  /home/preston/go/src/github.com/metaleap/go-xsd-pkg/www.w3.org/TR/2002/WD-SVG11-20020108/xlink.xsd_go/xlink.xsd.go
2017/05/18 18:57:16 GOINST: exec: "go-buildrun": executable file not found in $PATH
2017/05/18 18:57:16 LOAD:   www.w3.org/TR/2002/WD-SVG11-20020108/SVG.xsd
2017/05/18 18:57:16 MKPKG:  /home/preston/go/src/github.com/metaleap/go-xsd-pkg/www.w3.org/TR/2002/WD-SVG11-20020108/SVG.xsd_go/SVG.xsd.go
2017/05/18 18:57:16 GOINST: exec: "go-buildrun": executable file not found in $PATH
2017/05/18 18:57:16 LOAD:   www.w3.org/2007/schema-for-xslt20.xsd
2017/05/18 18:57:16 MKPKG:  /home/preston/go/src/github.com/metaleap/go-xsd-pkg/www.w3.org/2007/schema-for-xslt20.xsd_go/schema-for-xslt20.xsd.go
2017/05/18 18:57:16 GOINST: exec: "go-buildrun": executable file not found in $PATH
2017/05/18 18:57:16 LOAD:   www.w3.org/Math/XMLSchema/mathml2/common/xlink-href.xsd
2017/05/18 18:57:16 MKPKG:  /home/preston/go/src/github.com/metaleap/go-xsd-pkg/www.w3.org/Math/XMLSchema/mathml2/common/xlink-href.xsd_go/xlink-href.xsd.go
2017/05/18 18:57:16 GOINST: exec: "go-buildrun": executable file not found in $PATH
2017/05/18 18:57:16 LOAD:   www.w3.org/Math/XMLSchema/mathml2/mathml2.xsd
2017/05/18 18:57:16 MKPKG:  /home/preston/go/src/github.com/metaleap/go-xsd-pkg/www.w3.org/Math/XMLSchema/mathml2/mathml2.xsd_go/mathml2.xsd.go
2017/05/18 18:57:16 GOINST: exec: "go-buildrun": executable file not found in $PATH
2017/05/18 18:57:16 LOAD:   docs.oasis-open.org/election/external/xAL.xsd
2017/05/18 18:57:17 MKPKG:  /home/preston/go/src/github.com/metaleap/go-xsd-pkg/docs.oasis-open.org/election/external/xAL.xsd_go/xAL.xsd.go
2017/05/18 18:57:17 GOINST: exec: "go-buildrun": executable file not found in $PATH
2017/05/18 18:57:17 LOAD:   docbook.org/xml/5.0/xsd/xml.xsd
2017/05/18 18:57:17 MKPKG:  /home/preston/go/src/github.com/metaleap/go-xsd-pkg/docbook.org/xml/5.0/xsd/xml.xsd_go/xml.xsd.go
2017/05/18 18:57:17 GOINST: exec: "go-buildrun": executable file not found in $PATH
2017/05/18 18:57:17 LOAD:   docbook.org/xml/5.0/xsd/xlink.xsd
2017/05/18 18:57:17 MKPKG:  /home/preston/go/src/github.com/metaleap/go-xsd-pkg/docbook.org/xml/5.0/xsd/xlink.xsd_go/xlink.xsd.go
2017/05/18 18:57:17 GOINST: exec: "go-buildrun": executable file not found in $PATH
2017/05/18 18:57:17 LOAD:   docbook.org/xml/5.0/xsd/docbook.xsd
2017/05/18 18:57:17 MKPKG:  /home/preston/go/src/github.com/metaleap/go-xsd-pkg/docbook.org/xml/5.0/xsd/docbook.xsd_go/docbook.xsd.go
2017/05/18 18:57:17 GOINST: exec: "go-buildrun": executable file not found in $PATH
2017/05/18 18:57:17 LOAD:   kbcafe.com/rss/atom.xsd.xml
2017/05/18 18:57:17     ERROR: expected element type <schema> but have <HTML>
2017/05/18 18:57:17 LOAD:   thearchitect.co.uk/schemas/rss-2_0.xsd
2017/05/18 18:57:17 MKPKG:  /home/preston/go/src/github.com/metaleap/go-xsd-pkg/thearchitect.co.uk/schemas/rss-2_0.xsd_go/rss-2_0.xsd.go
2017/05/18 18:57:17 GOINST: exec: "go-buildrun": executable file not found in $PATH
2017/05/18 18:57:17 LOAD:   schemas.opengis.net/kml/2.2.0/atom-author-link.xsd
2017/05/18 18:57:17 MKPKG:  /home/preston/go/src/github.com/metaleap/go-xsd-pkg/schemas.opengis.net/kml/2.2.0/atom-author-link.xsd_go/atom-author-link.xsd.go
2017/05/18 18:57:17 GOINST: exec: "go-buildrun": executable file not found in $PATH
2017/05/18 18:57:17 LOAD:   schemas.opengis.net/kml/2.2.0/ogckml22.xsd
2017/05/18 18:57:18 MKPKG:  /home/preston/go/src/github.com/metaleap/go-xsd-pkg/schemas.opengis.net/kml/2.2.0/ogckml22.xsd_go/ogckml22.xsd.go
2017/05/18 18:57:18 GOINST: exec: "go-buildrun": executable file not found in $PATH
2017/05/18 18:57:18 LOAD:   khronos.org/files/collada_schema_1_4
2017/05/18 18:57:19 MKPKG:  /home/preston/go/src/github.com/metaleap/go-xsd-pkg/khronos.org/files/collada_schema_1_4_go/collada_schema_1_4.go
2017/05/18 18:57:20 GOINST: exec: "go-buildrun": executable file not found in $PATH
2017/05/18 18:57:20 LOAD:   khronos.org/files/collada_schema_1_5
2017/05/18 18:57:22 MKPKG:  /home/preston/go/src/github.com/metaleap/go-xsd-pkg/khronos.org/files/collada_schema_1_5_go/collada_schema_1_5.go
2017/05/18 18:57:23 GOINST: exec: "go-buildrun": executable file not found in $PATH

Then it didn't generate anything. I still just have my xsd file.

prestonvanloon commented 7 years ago

I figured it out after reading many of the issues.

I was expecting to do xsd-makepkg service.xsd and it output a service.xsd.go in the same working directory.

taiyangc commented 7 years ago

@prestonvanloon You can do so with xsd-makepkg -basepath="`pwd`" -uri="service.xsd"

TonyHoyle commented 6 years ago

The above command does not work. You just get ERROR: Get http://datafile.xsd: dial tcp: lookup service.xsd: no such host

Setting up a webserver is mandatory for this app, it seems. Very odd requirement..