sty_shared

package
v2024.8.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 17 Imported by: 4

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

View Source
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^%*^&%&*(%^*"
)
View Source
const (
	TEST_DOMAIN               = "savup.com"
	TEST_FILE_EXISTS_FILENAME = "file_exists.txt"
	TEST_FILE_UNREADABLE      = "unreadable_file.txt"
	TEST_INVALID_DOMAIN       = "tmp"
)

Variables

View Source
var (
	TEST_BYTE_ARRAY = []byte(TEST_STRING)
)

Functions

func Base64Decode

func Base64Decode(base64Value string) (
	value []byte,
	errorInfo pi.ErrorInfo,
)

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

func Base64Encode(value string) string

Base64Encode - will encode a string to a base64 string

Customer Messages: None
Errors: None
Verifications: None

func ConvertStringSliceToSliceOfPtrs

func ConvertStringSliceToSliceOfPtrs(inbound []string) (outbound []*string)

ConvertSliceToSliceOfPtrs - takes a slice and returns a slice of pointers to the items in the slice.

Customer Messages: None
Errors: None
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

func DoesDirectoryExist(directoryName string) bool

DoesDirectoryExist - checks is the directory exists

Customer Messages: None
Errors: None
Verifications: None

func DoesFieldExist

func DoesFieldExist(
	structType interface{},
	fieldName string,
) bool

DoesFieldExist - tests the struct for the field name.

Customer Messages: None
Errors: None
Verifications: None

func DoesFileExist

func DoesFileExist(fileName string) bool

DoesFileExist - does the value exist on the file system

Customer Messages: None
Errors: None
Verifications: None

func DoesFileExistsAndReadable

func DoesFileExistsAndReadable(filename, fileLabel string) (errorInfo pi.ErrorInfo)

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

func FloatToPennies(amount float64) (pennies int64)

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

func IsBase64Encode(base64Value string) bool

IsBase64Encode - will check if string is a valid base64 string.

Customer Messages: None
Errors: None
Verifications: None

func IsDirectoryFullyQualified

func IsDirectoryFullyQualified(directory string) bool

IsDirectoryFullyQualified - checks to see if the directory starts and ends with a slash.

Customer Messages: None
Errors: None
Verifications: None

func IsDomainValid

func IsDomainValid(domain string) bool

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

func IsEnvironmentValid(environment string) bool

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

func IsFileReadable(fileName string) bool

IsFileReadable - tries to open the file using 0644 permissions

Customer Messages: None
Errors: None
Verifications: None

func IsGinModeValid

func IsGinModeValid(mode string) bool

IsGinModeValid validates that the Gin httpServices framework mode is correctly set.

func IsIPAddressValid added in v2024.4.2

func IsIPAddressValid(ipAddress any) bool

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

func IsIPv4Valid(ipAddress any) bool

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

func IsIPv6Valid(ipAddress any) bool

IsIPv6Valid - checks if the data provide is a valid IPv6 address

Customer Messages: None
Errors: None
Verifications: None

func IsJSONValid

func IsJSONValid(jsonIn []byte) bool

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

func PrependWorkingDirectory(filename string) string

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

func PrependWorkingDirectoryWithEndingSlash(directory string) string

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

func RedirectLogOutput(
	inLogFileHandlerPtr *os.File,
	redirectTo string,
) (errorInfo pi.ErrorInfo)

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

func RemoveFile(fqn string) (errorInfo pi.ErrorInfo)

RemoveFile - removes a file for the file system.

Customer Messages: None
Errors: None
Verifications: None

func RemovePidFile

func RemovePidFile(pidFQN string) (errorInfo pi.ErrorInfo)

RemovePidFile - removes the pid file for the running instance

Customer Messages: None
Errors: None
Verifications: None

func ValidateDirectory

func ValidateDirectory(directory string) (errorInfo pi.ErrorInfo)

ValidateDirectory - validates that the directory value is not empty and the value exists on the file system

Customer Messages: None
Errors: None
Verifications: None

func WriteFile

func WriteFile(
	fqn string,
	fileData []byte,
	filePermissions os.FileMode,
) (errorInfo pi.ErrorInfo)

WriteFile - will create and write to a fully qualified file.

Customer Messages: None
Errors: ErrFileCreationFailed
Verifications: None

func WritePidFile

func WritePidFile(
	pidFQN string,
	pid int,
) (errorInfo pi.ErrorInfo)

WritePidFile - will create and write the server pid file.

Customer Messages: None
Errors: None
Verifications: None

Types

type FirebaseFirestoreHelper

type FirebaseFirestoreHelper struct {
	AppPtr              *firebase.App
	AuthPtr             *auth.Client
	FirestoreClientPtr  *firestore.Client
	CredentialsLocation string
}

Jump to

Keyboard shortcuts

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