json-gen-c  0.1.5
json-gen-c generate C code for json manipulation
gencode_go.c File Reference

Generate a Go source file (.go) with native encoding/json-compatible structs and type-safe enums from the parsed schema. The output is a single self-contained Go file using only the standard library. More...

#include "gencode/gencode.h"
#include "struct/struct_parse.h"
#include "utils/hash_map.h"
#include "utils/sstr.h"
#include <ctype.h>
#include <stdio.h>
#include <string.h>
Include dependency graph for gencode_go.c:

Classes

struct  go_emit_ctx
 
struct  dep_emit_ctx
 

Functions

int gencode_go (struct hash_map *struct_map, struct hash_map *enum_map, struct hash_map *oneof_map, const char *package_name, sstr_t output)
 generate a Go source file (.go) with native encoding/json-compatible structs and enums.
 

Detailed Description

Generate a Go source file (.go) with native encoding/json-compatible structs and type-safe enums from the parsed schema. The output is a single self-contained Go file using only the standard library.

Function Documentation

◆ gencode_go()

int gencode_go ( struct hash_map struct_map,
struct hash_map enum_map,
struct hash_map oneof_map,
const char *  package_name,
sstr_t  output 
)

generate a Go source file (.go) with native encoding/json-compatible structs and enums.

Parameters
struct_mapparsed struct definitions.
enum_mapparsed enum definitions.
oneof_mapparsed oneof (tagged union) definitions.
package_nameGo package name to use.
outputthe output Go source content.
Returns
0 on success, -1 on failure.