Documentation ¶
Overview ¶
Package sty_shared
This is the STY-Holdings shared services ¶
NOTES:
None
COPYRIGHT & WARRANTY:
Copyright (c) 2022 STY-Holdings, inc All rights reserved. This software is the confidential and proprietary information of STY-Holdings, Inc. Use is subject to license terms. Unauthorized copying of this file, via any medium is strictly prohibited. Proprietary and confidential Written by <Replace with FULL_NAME> / syacko STY-Holdings, Inc. support@sty-holdings.com www.sty-holdings.com 01-2024 USA 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 sty_shared
General description of the purpose of the go file.
RESTRICTIONS:
AWS functions: * Program must have access to a .awsServices/credentials file in the default location. * This will only access system parameters that start with '/sote' (ROOTPATH). * {Enter other restrictions here for AWS {Other catagories of restrictions} * {List of restrictions for the catagory
NOTES:
{Enter any additional notes that you believe will help the next developer.}
COPYRIGHT:
Copyright 2022 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 sty_shared
This is the STY-Holdings shared services ¶
NOTES:
None
COPYRIGHT & WARRANTY:
Copyright (c) 2022 STY-Holdings, inc All rights reserved. This software is the confidential and proprietary information of STY-Holdings, Inc. Use is subject to license terms. Unauthorized copying of this file, via any medium is strictly prohibited. Proprietary and confidential Written by <Replace with FULL_NAME> / syacko STY-Holdings, Inc. support@sty-holdings.com www.sty-holdings.com 01-2024 USA 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 Base64Decode(base64Value string) (value []byte, errorInfo pi.ErrorInfo)
- func Base64Encode(value string) string
- func ConvertStringSliceToSliceOfPtrs(inbound []string) (outbound []*string)
- func ConvertStructToMap(structIn interface{}) (mapOut map[string]interface{}, errorInfo pi.ErrorInfo)
- func CreateAndRedirectLogOutput(logDirectory, redirectTo string) (logFileHandlerPtr *os.File, logFQN string, errorInfo pi.ErrorInfo)
- func DoesDirectoryExist(directoryName string) bool
- func DoesFieldExist(structType interface{}, fieldName string) bool
- func DoesFileExist(fileName string) bool
- func DoesFileExistsAndReadable(filename, fileLabel string) (errorInfo pi.ErrorInfo)
- func FloatToPennies(amount float64) (pennies int64)
- func GetAWSTimestamp() (timestamp string)
- func GetFieldsNames(unknownStruct interface{}) (fields map[string]interface{}, errorInfo pi.ErrorInfo)
- func GetUnixTimestamp() (timestamp string)
- func GetUnixTimestampByte() (timestamp []byte)
- func IsBase64Encode(base64Value string) bool
- func IsDirectoryFullyQualified(directory string) bool
- func IsDomainValid(domain string) bool
- func IsEmpty(value interface{}) bool
- func IsEnvironmentValid(environment string) bool
- func IsFileReadable(fileName string) bool
- func IsGinModeValid(mode string) bool
- func IsIPAddressValid(ipAddress any) bool
- func IsIPv4Valid(ipAddress any) bool
- func IsIPv6Valid(ipAddress any) bool
- func IsJSONValid(jsonIn []byte) bool
- func IsPopulated(value interface{}) bool
- func PrependWorkingDirectory(filename string) string
- func PrependWorkingDirectoryWithEndingSlash(directory string) string
- func RedirectLogOutput(inLogFileHandlerPtr *os.File, redirectTo string) (errorInfo pi.ErrorInfo)
- func RemoveFile(fqn string) (errorInfo pi.ErrorInfo)
- func RemovePidFile(pidFQN string) (errorInfo pi.ErrorInfo)
- func ValidateDirectory(directory string) (errorInfo pi.ErrorInfo)
- func WriteFile(fqn string, fileData []byte, filePermissions os.FileMode) (errorInfo pi.ErrorInfo)
- func WritePidFile(pidFQN string, pid int) (errorInfo pi.ErrorInfo)
Constants ¶
const ( TEST_BASE64_STRING = "VEhpcyBpcyBhIHRlc3Qgc3RyaW5nIDEyMzQxMzQ1MjM1Nl4lKl4mJSYqKCVeKg==" TEST_FILE_NAME = "test_file.txt" TEST_DIRECTORY = "/tmp" TEST_DIRECTORY_ENDING_SLASH = "/tmp/" TEST_DIRECTORY_NON_ROOT = "shared-services" TEST_STRING = "THis is a test string 123413452356^%*^&%&*(%^*" )
const ( TEST_DOMAIN = "savup.com" TEST_FILE_EXISTS_FILENAME = "file_exists.txt" TEST_FILE_UNREADABLE = "unreadable_file.txt" TEST_INVALID_DOMAIN = "tmp" )
Variables ¶
var (
TEST_BYTE_ARRAY = []byte(TEST_STRING)
)
Functions ¶
func Base64Decode ¶
Base64Decode - will decode a base64 string to a string. If there is an error, the first 20 characters of the base64 string are logged. REMINDER: If the base64 string has sensitivity information, empty out the ErrorInfo.AdditionalInfo field before logging or outputting the error.
Customer Messages: None Errors: error returned by StdEncoding.DecodeString Verifications: None
func Base64Encode ¶
Base64Encode - will encode a string to a base64 string
Customer Messages: None Errors: None Verifications: None
func ConvertStringSliceToSliceOfPtrs ¶
ConvertSliceToSliceOfPtrs - takes a slice and returns a slice of pointers to the items in the slice.
Customer Messages: None Errors: None Verifications: None
func ConvertStructToMap ¶ added in v2024.10.0
func ConvertStructToMap(structIn interface{}) ( mapOut map[string]interface{}, errorInfo pi.ErrorInfo, )
ConvertStructToMap - converts a given struct to a map by marshaling it into JSON and then unmarshaling it into a map. If there is an error during the marshaling or unmarshaling process, the error information is returned.
Customer Messages: None Errors: error returned by json.Marshal and json.Unmarshal Verifications: None
func CreateAndRedirectLogOutput ¶
func CreateAndRedirectLogOutput(logDirectory, redirectTo string) ( logFileHandlerPtr *os.File, logFQN string, errorInfo pi.ErrorInfo, )
CreateAndRedirectLogOutput - will create the fully qualified config file log directory. The log output is based on the redirectTo value, [MODE_OUTPUT_LOG | MODE_OUTPUT_LOG_DISPLAY]. The log file name uses this format: 2006-01-02 15:04:05.000 Z0700. All spaces, colons, and periods are replaced with underscores.
Customer Messages: None Errors: ErrDirectoryNotFullyQualified, any error from os.OpenFile Verifications: IsDirectoryFullyQualified
func DoesDirectoryExist ¶
DoesDirectoryExist - checks is the directory exists
Customer Messages: None Errors: None Verifications: None
func DoesFieldExist ¶
DoesFieldExist - tests the struct for the field name.
Customer Messages: None Errors: None Verifications: None
func DoesFileExist ¶
DoesFileExist - does the value exist on the file system
Customer Messages: None Errors: None Verifications: None
func DoesFileExistsAndReadable ¶
DoesFileExistsAndReadable - works on any file. If the filename is not fully qualified the working directory will be prepended to the filename.
Customer Messages: None Errors: ErrFileMissing, ErrFileUnreadable Verifications: None
func FloatToPennies ¶
FloatToPennies - multiples the value by 100. Called pennies because we did for the US first.
Customer Messages: None Errors: None Verifications: None
func GetAWSTimestamp ¶ added in v2024.5.0
func GetAWSTimestamp() (timestamp string)
GetAWSTimestamp - gets date/time in AWS format (Mon Jan _2 15:04:05 MST 2006)
Customer Messages: None Errors: None Verifications: None
func GetFieldsNames ¶
func GetFieldsNames(unknownStruct interface{}) ( fields map[string]interface{}, errorInfo pi.ErrorInfo, )
GetFieldsNames - will return a list fields in a struct
Customer Messages: None Errors: None Verifications: None
func GetUnixTimestamp ¶ added in v2024.5.0
func GetUnixTimestamp() (timestamp string)
GetUnixTimestamp - gets date/time in unix format (Mon Jan _2 15:04:05 MST 2006)
Customer Messages: None Errors: None Verifications: None
func GetUnixTimestampByte ¶ added in v2024.5.0
func GetUnixTimestampByte() (timestamp []byte)
GetUnixTimestampByte - gets date/time in unix format (Mon Jan _2 15:04:05 MST 2006) as []byte
Customer Messages: None Errors: None Verifications: None
func IsBase64Encode ¶
IsBase64Encode - will check if string is a valid base64 string.
Customer Messages: None Errors: None Verifications: None
func IsDirectoryFullyQualified ¶
IsDirectoryFullyQualified - checks to see if the directory starts and ends with a slash.
Customer Messages: None Errors: None Verifications: None
func IsDomainValid ¶
IsDomainValid - checks if domain naming is followed
Customer Messages: None Errors: None Verifications: None
func IsEmpty ¶
func IsEmpty(value interface{}) bool
IsEmpty - checks that the value is empty.
Customer Messages: None Errors: None Verifications: None
func IsEnvironmentValid ¶
IsEnvironmentValid - checks that the value is valid. This function input is case-sensitive. Valid values are 'local', 'development', and 'production'.
Customer Messages: None Errors: None Verifications: None
func IsFileReadable ¶
IsFileReadable - tries to open the file using 0644 permissions
Customer Messages: None Errors: None Verifications: None
func IsGinModeValid ¶
IsGinModeValid validates that the Gin httpServices framework mode is correctly set.
func IsIPAddressValid ¶ added in v2024.4.2
IsIPAddressValid - checks if the data provide is a valid IP address
Customer Messages: None Errors: None Verifications: None
func IsIPv4Valid ¶ added in v2024.4.2
IsIPv4Valid - checks if the data provide is a valid IPv4 address
Customer Messages: None Errors: None Verifications: None
func IsIPv6Valid ¶ added in v2024.4.2
IsIPv6Valid - checks if the data provide is a valid IPv6 address
Customer Messages: None Errors: None Verifications: None
func IsJSONValid ¶
IsJSONValid - checks if the data provide is valid JSON.
Customer Messages: None Errors: None Verifications: None
func IsPopulated ¶
func IsPopulated(value interface{}) bool
IsPopulated - checks that the value is populated.
func PrependWorkingDirectory ¶
PrependWorkingDirectory - will add the working directory. if the filename first character is a /, the passed value will be returned unmodified.
Customer Messages: None Errors: None Verifications: None
func PrependWorkingDirectoryWithEndingSlash ¶
PrependWorkingDirectoryWithEndingSlash - will add the working directory, a slash, the directory provided, and an ending slash. If the directory first character is a slash, the passed value will be returned unmodified. The last character is not checked, so you could end up with two slashes.
Customer Messages: None Errors: None Verifications: None
func RedirectLogOutput ¶
RedirectLogOutput - will redirect log output based on the redirectTo value, [MODE_OUTPUT_LOG | MODE_OUTPUT_LOG_DISPLAY].
Customer Messages: None Errors: ErrDirectoryNotFullyQualified, any error from os.OpenFile Verifications: IsDirectoryFullyQualified
func RemoveFile ¶ added in v2024.7.1
RemoveFile - removes a file for the file system.
Customer Messages: None Errors: None Verifications: None
func RemovePidFile ¶
RemovePidFile - removes the pid file for the running instance
Customer Messages: None Errors: None Verifications: None
func ValidateDirectory ¶
ValidateDirectory - validates that the directory value is not empty and the value exists on the file system
Customer Messages: None Errors: None Verifications: None
Types ¶
This section is empty.