writer

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: BSD-3-Clause Imports: 14 Imported by: 0

README

GoCodeWriter

This repository contains an extraction of the code writer implementation used in the golang.org/x/text module for more convenient usage in other projects. Use under your own responsibility.

Acknowledgment

Much appreciation goes to the developers of the golang.org/x/text module.

License

see LICENSE

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Repackage

func Repackage(inFile, outFile, pkg string)

Repackage copies the given inFile to outFile adjusting the to the given package name. It assumes that the given inFile is in package main, panics otherwise.

func WriteGo

func WriteGo(w io.Writer, pkg, tags string, b []byte) (n int, err error)

func WriteGoFile

func WriteGoFile(filename, pkg string, b []byte) (n int)

WriteGoFile writes the go file with the given filename and pkg, and returns the size of the bytes written

Types

type Writer

type Writer struct {
	Size int
	Hash hash.Hash32 // content hash
	// contains filtered or unexported fields
}

func NewWriter added in v0.2.0

func NewWriter() *Writer

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

func (*Writer) WriteArray

func (w *Writer) WriteArray(x any)

func (*Writer) WriteComment

func (w *Writer) WriteComment(comment string, args ...any)

func (*Writer) WriteConst

func (w *Writer) WriteConst(name string, x any)

func (*Writer) WriteGo

func (w *Writer) WriteGo(out io.Writer, pkg, tags string) (n int, err error)

func (*Writer) WriteGoFile added in v0.2.0

func (w *Writer) WriteGoFile(filename, pkg string) (n int)

WriteGoFile writes the go file with the given filename and pkg, and returns the size of the bytes written

func (*Writer) WriteSlice

func (w *Writer) WriteSlice(x any)

func (*Writer) WriteString

func (w *Writer) WriteString(s string)

func (*Writer) WriteType

func (w *Writer) WriteType(x any) string

func (*Writer) WriteVar

func (w *Writer) WriteVar(name string, x any)

Jump to

Keyboard shortcuts

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