Skip to content


Folders and files

Last commit message
Last commit date

Latest commit



31 Commits

Repository files navigation


Go specgen is a minimalistic library for generating format specification into various languages.

It uses Go semantics (see drafts/foo.gspec.go) and currently generates the specifications to various formats.

Features / Things to do

  • Add more languages/formats
    • C/C++
    • Go
    • JSON
    • Markdown
    • Python
    • Rust
    • C#
    • Java
  • k-d array support
  • Improve error handling
  • Implement enum types
  • Make use of field tags

How to use

Simply go get or clone the repository.

Usage: Tool

You can compile go-specgen and use it as a tool to generate various outputs easily.

You can generate output to supported language by doing:

specgen --file=<path-to-file> --lang=<lang-mode>

such as

specgen --file=drafts/foo.gspec.go --lang=c

which will print out the output to the stdout stream.

For instance, you could pipe the output of Go lang into gofmt to get nicely formatted Go source code:

specgen --file=drafts/foo.gspec.go --lang=go | gofmt

Usage: Library

You can also use go-specgen as a library, for instance:

package main

import (


func main() {
    // Parse the gspec file containing data specifications
    ctx, err := gospec.ParseFile("drafts/foo.gspec.go")

    if err != nil {
        fmt.Printf("Error: %v\n", err)

    // Export it to Markdown tables

You can also look at main.go itself.


This project is licensed under Apache 2.0, see