Documentation ¶
Overview ¶
- Copyright 2022 ByteDance Inc. *
- 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.
This file may have been modified by Bytedance Ltd. and/or its affiliates (“Bytedance's Modifications”). All Bytedance's Modifications are Copyright (2022) Bytedance Ltd. and/or its affiliates.
This file may have been modified by Bytedance Ltd. and/or its affiliates (“Bytedance's Modifications”). All Bytedance's Modifications are Copyright (2022) Bytedance Ltd. and/or its affiliates.
Copyright 2022 ByteDance Inc. *
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 *
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 2022 ByteDance Inc. *
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 *
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 ¶
- func GetRandValueByType(typeValue string, isStars ...bool) string
- func MakeTimeStampMs(t time.Time) int64
- func RandChoice(choices ...string) string
- func RandomString(n int, allowedChars ...[]rune) string
- func ToStr(i interface{}) string
- type CallGraph
- type CalledRelation
- type CallerRelation
- type Expression
- type Field
- func (f *Field) GetImports(importsMap map[string]string)
- func (f *Field) GetRandValue(rootPath string) (res string)
- func (f *Field) GetStructFieldRandValue(rootPath string) (res string)
- func (f *Field) InitiateReceiver() string
- func (f *Field) InitiateReceiverForMock() string
- func (f *Field) InitiateStruct() string
- func (f *Field) InitiateVariable() string
- func (f *Field) IsBasicType() bool
- func (f *Field) IsInterface() bool
- func (f *Field) IsList() bool
- func (f *Field) IsMap() bool
- func (f *Field) IsNamed() bool
- func (f *Field) IsStar() bool
- func (f *Field) IsStruct() bool
- func (f *Field) IsWriter() bool
- func (f *Field) ShortName() string
- func (f *Field) ToString(rootPath string) string
- func (f *Field) ToStringForInitialVariable() string
- func (f *Field) ToStringForStruct() string
- type FuncDesc
- type Function
- func (f *Function) GetImports() []string
- func (f *Function) GetReceiverString() string
- func (f *Function) GetResult(sb *util.StringBuilder)
- func (f *Function) IsNaked() bool
- func (f *Function) MethodName() string
- func (f *Function) MockFunc() string
- func (f *Function) OnlyReturnsError() bool
- func (f *Function) OnlyReturnsOneValue() bool
- func (f *Function) ReturnsMultiple() bool
- func (f *Function) RootPath() string
- type Imethod
- type MWTNode
- type Options
- type ProjectFunction
- type ProjectProgram
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRandValueByType ¶
func RandChoice ¶
func RandomString ¶
Types ¶
type CallGraph ¶
type CallGraph struct { RootFunc *FuncDesc CallerRelationMap map[string]*CallerRelation }
type CalledRelation ¶
描述关键函数的一条反向调用关系
type CallerRelation ¶
描述一个函数调用N个函数的一对多关系
type Expression ¶
type Expression struct { Value string //没有[]以及*的类型 PkgPath string // 如果map结构,那么PkgPath表示的是key的包路径 PkgName string IsStar bool //是否指针 IsStruct bool IsVariadic bool //是否...模拟数组的形式 IsWriter bool Underlying string //golang类型 ExtraPkgPaths []string IsSignature bool }
func (*Expression) String ¶
func (e *Expression) String() string
func (*Expression) ToString ¶
func (e *Expression) ToString(rootPath string) string
type Field ¶
type Field struct { Name string Type *Expression Index int Fields []*Field }
func (*Field) GetImports ¶
func (*Field) GetRandValue ¶
func (*Field) GetStructFieldRandValue ¶
func (*Field) InitiateReceiver ¶
func (*Field) InitiateReceiverForMock ¶
func (*Field) InitiateStruct ¶
func (*Field) InitiateVariable ¶
InitiateVariable used for gotype dynamic transformation
func (*Field) IsBasicType ¶
func (*Field) IsInterface ¶
func (*Field) ToStringForInitialVariable ¶
ToStringForInitialVariable only used for the signature
func (*Field) ToStringForStruct ¶
type FuncDesc ¶
type FuncDesc struct { File string //文件路径 Path string //文件路径 Package string //package名 Name string //函数名,格式为Package.Func }
函数定义
type Function ¶
type Function struct { RootFunc *Function PkgPath string PkgName string Name string IsExported bool Receiver *Field Parameters []*Field Results []*Field ReturnsError bool NeedRandCase bool // contains filtered or unexported fields }
func (*Function) GetImports ¶
func (*Function) GetReceiverString ¶
func (*Function) GetResult ¶
func (f *Function) GetResult(sb *util.StringBuilder)