2.1.0 • Published 3 years ago

go-const-gen v2.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

go-const-gen

JSON to Go constants.

Installation

yarn add go-const-gen

Example

import goConstGen from 'go-const-gen';

(async () => {
  const result = await goConstGen(
    {
      hello: '1',
      world: '2',
      intProp: 123,
      doubleProp: 12.3,
    },
    { packageName: 'test', typeName: 'Test' },
    'basic',
  );
  console.log(result);
})();

It prints:

******************************************************************************************
* This code was automatically generated by go-const-gen.
* Do not edit this file manually, your changes will be overwritten.
******************************************************************************************/

package test

// Test ...
type Test struct {
	DoubleProp float64 `json:"doubleProp"`
	Hello      string  `json:"hello"`
	IntProp    int     `json:"intProp"`
	World      string  `json:"world"`
}