Documentation ¶
Overview ¶
Package files contains file-related utilities.
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
Index ¶
- Constants
- func Execute()
- func Generate(dir string, pkgs []string, opt Options) error
- func ImportsCode(code string) ([]byte, error)
- func Struct2Interface(cmd *cobra.Command, dir string) error
- func Watch(watcher Watcher, dir string, callback func(), verbose bool)
- type Method
- type Options
- type Watcher
- type Writer
Constants ¶
const (
Usage = `` /* 1186-byte string literal not displayed */
)
Variables ¶
This section is empty.
Functions ¶
func Execute ¶
func Execute()
Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.
func Generate ¶
Generate generates Kod code for the specified packages. The list of supplied packages are treated similarly to the arguments passed to "go build" (see "go help packages" for details).
func ImportsCode ¶
Types ¶
type Options ¶
type Options struct { // If non-nil, use the specified function to report warnings. Warn func(error) }
Options controls the operation of Generate.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer writes a sequence of bytes to a file. In case of errors, the old file contents remain untouched since the writes are applied atomically when the Writer is closed.
func NewWriter ¶
NewWriter returns a writer that writes to the named files.
The caller should eventually call Cleanup. A recommended pattern is:
w := files.NewWriter(dst) defer w.Cleanup() ... write to w ... err := w.Close()
func (*Writer) Cleanup ¶
func (w *Writer) Cleanup()
Cleanup releases any resources in use by the writer, without attempting to write collected bytes to the destination. It is safe to call Cleanup() even if Close or Cleanup have already been called.