fillstruct

command
v0.0.0-...-52d6a69 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2019 License: Apache-2.0, BSD-2-Clause Imports: 18 Imported by: 0

README

fillstruct Build Status GoDoc Go Report Card

fillstruct - fills a struct literal with default values


For example, given the following types,

type User struct {
	ID   int64
	Name string
	Addr *Address
}

type Address struct {
	City   string
	ZIP    int
	LatLng [2]float64
}

the following struct literal

var frank = User{}

becomes:

var frank = User{
	ID:   0,
	Name: "",
	Addr: &Address{
		City: "",
		ZIP:  0,
		LatLng: [2]float64{
			0.0,
			0.0,
		},
	},
}

after applying fillstruct.

Installation

% go get -u github.com/davidrjenni/reftools/cmd/fillstruct

Usage

% fillstruct [-modified] -file=<filename> -offset=<byte offset>

Flags:

-file:     filename
-modified: read an archive of modified files from stdin
-offset:   byte offset of the struct literal

Documentation

Overview

Fillstruct fills a struct literal with default values.

For example, given the following types,

type User struct {
	ID   int64
	Name string
	Addr *Address
}

type Address struct {
	City   string
	ZIP    int
	LatLng [2]float64
}

the following struct literal

var frank = User{}

becomes:

var frank = User{
	ID:   0,
	Name: "",
	Addr: &Address{
		City: "",
		ZIP:  0,
		LatLng: [2]float64{
			0.0,
			0.0,
		},
	},
}

after applying fillstruct.

Usage:

% fillstruct [-modified] -file=<filename> -offset=<byte offset>

Flags:

-file: filename

-modified: read an archive of modified files from stdin

-offset: byte offset of the struct literal

Jump to

Keyboard shortcuts

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