-
-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added option to disable XML fields/import when using Go #60
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR. I've left some comments.
pkgPtr := flag.String("p", "", "Specify the package name") | ||
langPtr := flag.String("l", "", "Specify the language of generated code") | ||
verPtr := flag.Bool("v", false, "Show version and exit") | ||
helpPtr := flag.Bool("h", false, "Show this help and exit") | ||
flag.Parse() | ||
if *helpPtr { | ||
fmt.Printf("xgen version: %s\r\nCopyright (c) 2020 - 2021 Ri Xu https://xuri.me All rights reserved.\r\n\r\nUsage:\r\n$ xgen [<flag> ...] <XSD file or directory> ...\n -i <path>\tInput file path or directory for the XML schema definition\r\n -o <path>\tOutput file path or directory for the generated code\r\n -p \tSpecify the package name\r\n -l \tSpecify the language of generated code (Go/C/Java/Rust/TypeScript)\r\n -h \tOutput this help and exit\r\n -v \tOutput version and exit\r\n", Cfg.Version) | ||
fmt.Printf("xgen version: %s\r\nCopyright (c) 2020 - 2021 Ri Xu https://xuri.me All rights reserved.\r\n\r\nUsage:\r\n$ xgen [<flag> ...] <XSD file or directory> ...\n -i <path>\tInput file path or directory for the XML schema definition\r\n -o <path>\tOutput file path or directory for the generated code\r\n -p \tSpecify the package name\r\n -l \tSpecify the language of generated code (Go/C/Java/Rust/TypeScript)\r\n --noxml \tDon't generate XMLName fields on structs (Go)\r\n -h \tOutput this help and exit\r\n -v \tOutput version and exit\r\n", Cfg.Version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The doc in the README.md
also needs to update.
@@ -62,13 +63,14 @@ var SupportLang = map[string]bool{ | |||
func parseFlags() *Config { | |||
iPtr := flag.String("i", "", "Input file path or directory for the XML schema definition") | |||
oPtr := flag.String("o", "xgen_out", "Output file path or directory for the generated code") | |||
noXmlName := flag.Bool("noxml", false, "Don't add xmlName fields") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest that using the --skip-go-xml-name
instead of noxml
, will be more clear.
Description
Generated structs are given an XMLName field + encoding/xml import.
Sometimes you may not want this, for example when using an XSD just to generate structs for some other application than XML-parsing.
This feature adds a commandline option to omit those fields:
Types of changes