talira

Helper modules for Go: type conversion, JSON and YAML utilities, name mangling

open sourceApache-2.0free

swag is a collection of relatively independent Go helper modules from the go-openapi project. Most go-openapi repositories and the go-swagger CLI depend on it, and it can be used on its own. Its modules cover type conversion between values, pointers and strings, JSON utilities (fast concatenation, reading and writing dynamic data), YAML utilities (converting YAML to JSON and keeping key order), loading files from disk or HTTP, safe Go name mangling, networking, string and type helpers, sync.Pool helpers and CLI utilities. The top-level package is kept for backward compatibility, and its exported features are deprecated in favour of the child modules.

Problems it solves

  • convert YAML to JSON in Go and keep the original key order
  • turn a value into a pointer and back for any type in Go
  • generate safe Go identifiers from arbitrary names

Features

  • Type conversion between values, pointers and strings
  • JSON utilities with pluggable adapters, standard library by default
  • YAML to JSON conversion that keeps key order
  • Loads files from disk or over HTTP
  • Safe Go name mangling
  • Independent child modules you import one at a time

Limitations

  • The top-level package's exported features are deprecated: new code should import the child modules1