gen

package
v0.0.0-...-bc2ff70 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Copyright © 2020 aggronmagi <czy463@163.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright © 2020 aggronmagi <czy463@163.com>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright © 2020 aggronmagi <czy463@163.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstallOptionsWatchDog

func InstallOptionsWatchDog(dog func(cc *Options))

InstallOptionsWatchDog install watch dog

func Title

func Title(in string) (out string)

Types

type Generator

type Generator struct {
	*bytes.Buffer
	// contains filtered or unexported fields
}

Generator 生成器

func New

func New(opts ...Option) *Generator

New 新建生成器

func (*Generator) BeginLine

func (gen *Generator) BeginLine()

BeginLine 行开始

func (*Generator) Bytes

func (gen *Generator) Bytes() (data []byte, err error)

GoFmtByest go文件格式化

func (*Generator) Doc

func (gen *Generator) Doc(doc *buildpb.DocDesc)

func (*Generator) EndLine

func (gen *Generator) EndLine()

EndLine 行结束

func (*Generator) Error

func (gen *Generator) Error(err error, msgs ...string)

Error reports a problem, including an error, and exits the program.

func (*Generator) Fail

func (gen *Generator) Fail(msgs ...string)

Fail reports a problem and exits the program.

func (*Generator) In

func (gen *Generator) In()

In Indents the output one tab stop.

func (*Generator) Key

func (gen *Generator) Key(k string) string

func (*Generator) LuaDoc

func (gen *Generator) LuaDoc(doc *buildpb.DocDesc)

func (*Generator) Out

func (gen *Generator) Out()

Out unindents the output one tab stop.

func (*Generator) P

func (gen *Generator) P(str ...interface{})

P 同 Println

func (*Generator) Pf

func (gen *Generator) Pf(fmts string, v ...interface{})

Pf 同 Printf

func (*Generator) PopAndWrite

func (gen *Generator) PopAndWrite()

PopAndWrite 出栈

func (*Generator) Print

func (gen *Generator) Print(str ...interface{})

Print 打印数据

func (*Generator) Printf

func (gen *Generator) Printf(fmts string, v ...interface{})

Printf

func (*Generator) Println

func (gen *Generator) Println(str ...interface{})

Println 打印数据

func (*Generator) PushObj

func (gen *Generator) PushObj()

PushObj 入栈

func (*Generator) WriteString

func (gen *Generator) WriteString(str string)

WriteString 写string

type Option

type Option func(cc *Options) Option

Option option define

func WithGoFmt

func WithGoFmt(v bool) Option

Go格式化

func WithIndent

func WithIndent(v string) Option

缩进

func WithKeyTitle

func WithKeyTitle(v bool) Option

key 是否大写

type Options

type Options struct {
	// 缩进
	Indent string
	// Go格式化
	GoFmt bool
	// key 是否大写
	KeyTitle bool
}

func NewOptions

func NewOptions(opts ...Option) *Options

NewOptions create options instance.

func (*Options) ApplyOption

func (cc *Options) ApplyOption(opts ...Option)

ApplyOption modify options

func (*Options) GetSetOption

func (cc *Options) GetSetOption(opt Option) Option

GetSetOption modify and get last option

func (*Options) SetOption

func (cc *Options) SetOption(opt Option)

SetOption modify options

Jump to

Keyboard shortcuts

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