accessor

command module
v0.0.0-...-fb723cd Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2018 License: MIT Imports: 14 Imported by: 0

README

Accessor

generate getter and setter for unexported struct field

Install

$ go get -u github.com/mizkei/accessor

Example

package types

import (
	"time"
)

// Example is example
//go:generate accessor -setter -type=Example
type Example struct {
	A int
	b string
	c time.Time
}

execute go generate

output

// Code generated by "accessor -setter -type=Example"; DO NOT EDIT.

package types

import "time"

// B return b value
func (t Example) B() string {
	return t.b
}

// SetB set v to b
func (t *Example) SetB(v string) {
	t.b = v
}

// C return c value
func (t Example) C() time.Time {
	return t.c
}

// SetC set v to c
func (t *Example) SetC(v time.Time) {
	t.c = v
}

TODO

  • test
  • generate anonymous struct type
  • use field tag

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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