github.com/randomizedcoder/goTrackRTP@v0.0.2/cmd/enum_gen/enum_gen.go (about)

     1  package main
     2  
     3  // Nasty enum code generator for trackingRing
     4  // Honestly, it might be better to use protobufs....
     5  
     6  import (
     7  	"fmt"
     8  	"log"
     9  )
    10  
    11  var (
    12  	position    = []string{"Unknown", "Ahead", "Behind"}
    13  	category    = []string{"Unknown", "Window", "Buffer", "Reset"}
    14  	subcategory = []string{"Unknown", "Next", "Duplicate"}
    15  )
    16  
    17  func main() {
    18  
    19  	log.Println("enum_gen")
    20  
    21  	fmt.Printf("const (\n")
    22  
    23  	for i, p := range position {
    24  		for j, c := range category {
    25  			for k, s := range subcategory {
    26  				fmt.Printf("\t%s%s%s", p, c, s)
    27  				if i == 0 && j == 0 && k == 0 {
    28  					fmt.Printf(" int = iota")
    29  				}
    30  				fmt.Printf("\n")
    31  			}
    32  		}
    33  	}
    34  
    35  	fmt.Printf(")\n")
    36  }