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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
Index ¶
- Constants
- Variables
- func Contains(slice []string, item string) bool
- func DeepCopy(s string) string
- func DeepCopySlice(bytes []byte) []byte
- func FloatEquals(a, b float64) bool
- func GetCurrentProjectRootPath() string
- func GetParentDirectory(dirctory string) string
- func GetPkgName(path string) string
- func GetPkgNameV2(strExp string) string
- func GetRandomFloat() float64
- func GetRepoByRelativePath(relativePath string) string
- func GetTheReceiveNameFromSSA(s string) string
- func GetUseMockByVersion(path string) int
- func GetValue(t reflect.Type, level int) (reflect.Value, error)
- func IsBasicDataType(t string) bool
- func IsExportByName(name string) bool
- func IsFileExist(path string) bool
- func IsSystemPkg(path string) bool
- func IsTypeArray(typ reflect.Type) bool
- func IsTypeCollection(typ reflect.Type) bool
- func IsTypeExported(t reflect.Type) bool
- func IsTypeFunction(typ reflect.Type) bool
- func IsTypeImplementsContext(typ reflect.Type) bool
- func IsTypeImplementsError(typ reflect.Type) bool
- func IsTypeIteratee(typ reflect.Type) bool
- func IsTypeMap(typ reflect.Type) bool
- func IsTypeSlice(typ reflect.Type) bool
- func IsValueNil(value reflect.Value) bool
- func LintPackageComment(path string) ([]string, error)
- func RandStringBytes(n int) string
- func RandomBool(rate float64) bool
- func RandomFloat(min float64, max float64) float64
- func RandomInt(parameters ...int) (p []int, err error)
- func RecoverOriginalFile(content []byte, path string) error
- func RemoveCStyleComments(content []byte) []byte
- func RemoveDirectory(dirName string)
- func RemoveGoComments(path string) ([]byte, error)
- func RemoveGoStyleComments(content []byte, comments []string) []byte
- func RemoveLastFilePath(s string) string
- func RemoveTestCaseFile(dirName, fileName string)
- func ReplacePkgName(s string, pkgName string, originalPkgName string) string
- func ReplacePkgNameForMap(s string, pkgName string, originalPkgName string, fromLeft bool) string
- func UpperCaseFirstLetter(s string) string
- type GoVersionInfo
- type Plugin
- type RWLocker
- type TaggedFunction
Constants ¶
const ( ID = "uuid_digit" HyphenatedID = "uuid_hyphenated" EmailTag = "email" MacAddressTag = "mac_address" DomainNameTag = "domain_name" UserNameTag = "username" URLTag = "url" IPV4Tag = "ipv4" IPV6Tag = "ipv6" PASSWORD = "password" JWT = "jwt" LATITUDE = "lat" LONGITUDE = "long" CreditCardNumber = "cc_number" CreditCardType = "cc_type" PhoneNumber = "phone_number" TollFreeNumber = "toll_free_number" E164PhoneNumberTag = "e_164_phone_number" TitleMaleTag = "title_male" TitleFemaleTag = "title_female" FirstNameTag = "first_name" FirstNameMaleTag = "first_name_male" FirstNameFemaleTag = "first_name_female" LastNameTag = "last_name" NAME = "name" GENDER = "gender" UnixTimeTag = "unix_time" DATE = "date" TIME = "time" MonthNameTag = "month_name" YEAR = "year" DayOfWeekTag = "day_of_week" DayOfMonthTag = "day_of_month" TIMESTAMP = "timestamp" CENTURY = "century" TIMEZONE = "timezone" TimePeriodTag = "time_period" WORD = "word" SENTENCE = "sentence" PARAGRAPH = "paragraph" CurrencyTag = "currency" AmountTag = "amount" AmountWithCurrencyTag = "amount_with_currency" SKIP = "-" Length = "len" SliceLength = "slice_len" Language = "lang" BoundaryStart = "boundary_start" BoundaryEnd = "boundary_end" Equals = "=" ONEOF = "oneof" )
Supported tags
Variables ¶
var ( // LangENG is for english language LangENG = langRuneBoundary{65, 122, []rune{91, 92, 93, 94, 95, 96}} // LangCHI is for chinese language LangCHI = langRuneBoundary{19968, 40869, nil} // LangRUS is for russian language LangRUS = langRuneBoundary{1025, 1105, nil} )
Language rune boundaries here
var ( ErrUnsupportedKindPtr = "Unsupported kind: %s Change Without using * (pointer) in Field of %s" ErrUnsupportedKind = "Unsupported kind: %s" ErrValueNotPtr = "Not a pointer value" ErrTagNotSupported = "Tag unsupported: %s" ErrTagAlreadyExists = "Tag exists" ErrTagDoesNotExist = "Tag does not exist" ErrMoreArguments = "Passed more arguments than is possible : (%d)" ErrNotSupportedPointer = "Use sample:=new(%s)\n faker.FakeData(sample) instead" ErrSmallerThanZero = "Size:%d is smaller than zero." ErrSmallerThanOne = "Size:%d is smaller than one." ErrUniqueFailure = "Failed to generate a unique value for field \"%s\"" ErrStartValueBiggerThanEnd = "Start value can not be bigger than end value." ErrWrongFormattedTag = "Tag \"%s\" is not written properly" ErrUnknownType = "Unknown Type" ErrNotSupportedTypeForTag = "Type is not supported by tag." ErrUnsupportedTagArguments = "Tag arguments are not compatible with field type." ErrDuplicateSeparator = "Duplicate separator for tag arguments." ErrNotEnoughTagArguments = "Not enough arguments for tag." ErrUnsupportedNumberType = "Unsupported Number type." )
Generic Error Messages for tags
ErrUnsupportedKindPtr: Error when get fake from ptr ErrUnsupportedKind: Error on passing unsupported kind ErrValueNotPtr: Error when value is not pointer ErrTagNotSupported: Error when tag is not supported ErrTagAlreadyExists: Error when tag exists and call AddProvider ErrTagDoesNotExist: Error when tag does not exist and call RemoveProvider ErrMoreArguments: Error on passing more arguments ErrNotSupportedPointer: Error when passing unsupported pointer
var EPSILON = 0.00000001
var GoKeywords = []string{
"interface", "break", "default", "func", "select",
"case", "defer", "go", "map", "struct",
"chan", "else", "goto", "package", "switch",
"const", "fallthrough", "if", "range ", "type",
"continue", "for", "import", "return", "var"}
var MapperTag = mapperTag
Functions ¶
func DeepCopySlice ¶
func FloatEquals ¶
func GetCurrentProjectRootPath ¶
func GetCurrentProjectRootPath() string
func GetParentDirectory ¶
func GetPkgName ¶
func GetRandomFloat ¶
func GetRandomFloat() float64
func GetRepoByRelativePath ¶
func GetTheReceiveNameFromSSA ¶
The receive name like:
var github.com/bytedance/nxt_unit/unittesttemplate.TikTokConsumption var *github.com/bytedance/nxt_unit/unittesttemplate.TikTokConsumption
func GetUseMockByVersion ¶
func IsBasicDataType ¶
func IsExportByName ¶
func IsFileExist ¶
func IsSystemPkg ¶
func IsTypeArray ¶
IsTypeArray returns if argument is array type
func IsTypeCollection ¶
IsTypeCollection returns if the argument is a slice/array.
func IsTypeExported ¶
func IsTypeFunction ¶
IsTypeFunction returns if the argument is reflect.Func.
func IsTypeImplementsContext ¶
IsTypeImplementsContext returns if the argument is impl of context.Context
func IsTypeImplementsError ¶
IsTypeImplementsError returns if the argument is impl of error
func IsTypeIteratee ¶
IsTypeIteratee returns if the argument is an iteratee.
func IsTypeSlice ¶
IsTypeSlice returns if argument is slice type
func IsValueNil ¶
IsValueNil returns if reflect.Value is nil. panics when value is invalid.
func RandStringBytes ¶
func RandomBool ¶
func RandomFloat ¶
func RandomInt ¶
RandomInt Get three parameters , only first mandatory and the rest are optional
If only set one parameter : This means the minimum number of digits and the total number If only set two parameters : First this is min digit and second max digit and the total number the difference between them If only three parameters: the third argument set Max count Digit
func RecoverOriginalFile ¶
func RemoveCStyleComments ¶
func RemoveDirectory ¶
func RemoveDirectory(dirName string)
func RemoveGoComments ¶
func RemoveGoStyleComments ¶
func RemoveLastFilePath ¶
func RemoveTestCaseFile ¶
func RemoveTestCaseFile(dirName, fileName string)
func ReplacePkgNameForMap ¶
func UpperCaseFirstLetter ¶
UpperCaseFirstLetter won't change the input string.
Types ¶
type GoVersionInfo ¶
func GetGoVersion ¶
func GetGoVersion(path string) (GoVersionInfo, error)
type TaggedFunction ¶
TaggedFunction used as the standard layout function for tag providers in struct. This type also can be used for custom provider.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
* Copyright 2022 ByteDance Inc.
|
* Copyright 2022 ByteDance Inc. |
* Copyright 2022 ByteDance Inc.
|
* Copyright 2022 ByteDance Inc. |
testase
|
|
user_security
* Copyright 2022 ByteDance Inc.
|
* Copyright 2022 ByteDance Inc. |
* Copyright 2022 ByteDance Inc.
|
* Copyright 2022 ByteDance Inc. |