go-genprop

module
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2024 License: MIT

README

genprop

Generates getter/setter functions of private field.

INSTALL

go install github.com/hidori/go-genprop/cmd/genprop@latest

USAGE

usage: genprop [OPTION]... <FILE>

option(s):
  -initialism string
        names to which initialism should be applied (default "id,url,api")

EXAMPLE

example.go

package example

type ExampleAliasType = int // ignored

type ExampleDefinedType int // ignored

type ExampleStruct struct {
 value0 int    // ignored
 value1 int    `property:"get"`
 value2 int    `property:"set"`
 value3 int    `property:"get,set"`
 id     int    `property:"get"`
 api    string `property:"get"`
 url    string `property:"get"`
 http   string `property:"get"`
}

run CLI

genprop example.go > example.prop.go

example.prop.go

// Code generated by github.com/hidori/go-genprop/cmd/genprop DO NOT EDIT.
package example

func (t *ExampleStruct) GetValue1() int {
 return t.value1
}
func (t *ExampleStruct) SetValue2(v int) {
 t.value2 = v
}
func (t *ExampleStruct) GetValue3() int {
 return t.value3
}
func (t *ExampleStruct) SetValue3(v int) {
 t.value3 = v
}
func (t *ExampleStruct) GetID() int {
 return t.id
}
func (t *ExampleStruct) GetAPI() string {
 return t.api
}
func (t *ExampleStruct) GetURL() string {
 return t.url
}
func (t *ExampleStruct) GetHttp() string {
 return t.http
}

Directories

Path Synopsis
app
cmd
Code generated by github.com/hidori/go-genprop/cmd/genprop DO NOT EDIT.
Code generated by github.com/hidori/go-genprop/cmd/genprop DO NOT EDIT.
test

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL