Documentation ¶
Overview ¶
Copyright 2023 API Testing Authors.
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.
Package util provides a set of common functions ¶
Copyright 2023 API Testing Authors.
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 2023 API Testing Authors.
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 2023 API Testing Authors.
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 2023 API Testing Authors.
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 2023 API Testing Authors.
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 2023 API Testing Authors.
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.
Package util provides utilities related to randomization.
Copyright 2023 API Testing Authors.
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
- func EmptyThenDefault(val, defVal string) string
- func ErrorWrap(err error, msg string, args ...interface{}) error
- func Expand(text string) (result []string)
- func GetDefaultCachedHTTPClient() *http.Client
- func GetFirstHeaderValue(header http.Header, key string) (val string)
- func IgnoreErrServerClosed(err error) error
- func Keys[T interface{}](data map[string]T) (keys []string)
- func LoadProtoFiles(protoFile string) (targetProtoFile string, importPath []string, protoParentDir string, err error)
- func MakeSureNotNil[T any](inter T) T
- func OKOrErrorMessage(err error) string
- func OrErrorMessage(err error, message string) string
- func PathExists(path string) (ok bool, err error)
- func RemoeEmptyFromSlice(items []string) []string
- func String(n int) string
- func TlsAwareHTTPClient(insecure bool) *http.Client
- func ZeroThenDefault(val, defVal int) int
Constants ¶
const ( ContentType = "Content-Type" ContentDisposition = "Content-Disposition" MultiPartFormData = "multipart/form-data" Form = "application/x-www-form-urlencoded" JSON = "application/json" YAML = "application/yaml" ZIP = "application/zip" OctetStream = "application/octet-stream" Plain = "text/plain" Authorization = "Authorization" )
ContentType is the HTTP header key
Variables ¶
This section is empty.
Functions ¶
func EmptyThenDefault ¶ added in v0.0.13
EmptyThenDefault return the default value if the val is empty
func Expand ¶ added in v0.0.12
Expand the text with brace syntax. Such as: /home/{good,bad} -> [/home/good, /home/bad]
func GetDefaultCachedHTTPClient ¶ added in v0.0.15
func GetFirstHeaderValue ¶ added in v0.0.14
GetFirstHeaderValue retursn the first value of the header
func IgnoreErrServerClosed ¶ added in v0.0.14
IgnoreErrServerClosed ignores ErrServerClosed
func LoadProtoFiles ¶ added in v0.0.15
func MakeSureNotNil ¶
func MakeSureNotNil[T any](inter T) T
MakeSureNotNil makes sure the parameter is not nil
func OKOrErrorMessage ¶ added in v0.0.13
OKOrErrorMessage returns OK or error message
func OrErrorMessage ¶ added in v0.0.13
OrErrorMessage returns error message or message
func PathExists ¶ added in v0.0.13
PathExists checks if the target path exist or not
func RemoeEmptyFromSlice ¶ added in v0.0.14
func String ¶
String generates a random alphanumeric string, without vowels, which is n characters long. This will panic if n is less than zero. How the random string is created: - we generate random int63's - from each int63, we are extracting multiple random letters by bit-shifting and masking - if some index is out of range of alphanums we neglect it (unlikely to happen multiple times in a row)
func TlsAwareHTTPClient ¶ added in v0.0.15
func ZeroThenDefault ¶ added in v0.0.13
ZeroThenDefault return the default value if the val is zero
Types ¶
This section is empty.