Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SaschaMendel
Copy link

Description

Generated structs are given an XMLName field + encoding/xml import.

XMLName          xml.Name          `json:"XMLName"

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:

  --noxml     	Don't generate XMLName fields on structs (Go)

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Copy link
Owner

@xuri xuri left a 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)
Copy link
Owner

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")
Copy link
Owner

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.

@xuri xuri added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Nov 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants