utils

package
v1.1.17 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendFile added in v1.1.11

func AppendFile(filename string) *os.File

func CreateFile added in v1.1.11

func CreateFile(filename string) *os.File

func PackageAndFuncs

func PackageAndFuncs(files ...string) (string, []string)

PackageAndFuncs 解析Go源程序包和方法.

func PackageAndStructs added in v1.1.11

func PackageAndStructs(files ...string) (string, []string)

func Parse

func Parse(files ...string) (*ast.File, error)

Parse Go源程序解析.

func SnakeCase added in v1.1.11

func SnakeCase(camelCase string) string

func UseCobra

func UseCobra(root *ast.File) bool

UseCobra 判断是否使用 spf13/cobra.

Types

type Source added in v1.1.12

type Source struct {
	Package string
	Funcs   []string
	Structs []*Struct
}

func NewSource added in v1.1.12

func NewSource(files ...string) (*Source, error)
Example

ExampleNewSource is an example function.

package main

import (
	"fmt"

	"github.com/xuender/go-cli/utils"
)

func main() {
	source, err := utils.NewSource("source.go")
	fmt.Println(err)
	fmt.Println(source.Funcs)
	fmt.Println(source.Structs[0].FieldNames)

}
Output:

<nil>
[Struct_String NewStruct NewSource]
[Package Funcs Structs]

type Struct added in v1.1.12

type Struct struct {
	Name       string
	FieldNames []string
	Fields     []*ast.Field
}

func NewStruct added in v1.1.12

func NewStruct(name string, stu *ast.StructType) *Struct

func (*Struct) String added in v1.1.12

func (p *Struct) String() string

Jump to

Keyboard shortcuts

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