utils

package
v0.0.0-...-8253c4d Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package utils is used for functions that are used in multiple locations

Index

Examples

Constants

This section is empty.

Variables

View Source
var Logger *log.Logger

Functions

func GetFileHash

func GetFileHash(filepath string) (string, error)
Example

ExampleGetFileHash provides an example of how to use the function

// Create a temporary file for the example
tmpfile, err := os.CreateTemp("", "example")
if err != nil {
	fmt.Printf("Failed to create temp file: %v\n", err)
	return
}
defer os.Remove(tmpfile.Name())

// Write some content to the file
content := []byte("Hello, World!")
if _, err := tmpfile.Write(content); err != nil {
	fmt.Printf("Failed to write to temp file: %v\n", err)
	return
}
tmpfile.Close()

// Get the hash
_, err = GetFileHash(tmpfile.Name())
if err != nil {
	fmt.Printf("Failed to get hash: %v\n", err)
	return
}

fmt.Println("Hash calculated successfully")
Output:

Hash calculated successfully

func LogErrorDefaultFormat

func LogErrorDefaultFormat(packageName, callerName string, err error, action string)

LogErrorDefaultFormat is used to print errors in a uniform way

func LogFatalDefaultFormat

func LogFatalDefaultFormat(packageName, callerName string, err error, action string)

LogFatalDefaultFormat is used to print errors in a uniform way, and exit with a Panic

func LogPanicDefaultFormat

func LogPanicDefaultFormat(packageName, callerName string, err error, action string)

LogPanicDefaultFormat is used to print errors in a uniform way, and exit with a Panic

func NewLogger

func NewLogger(lvl log.Level) *log.Logger

NewLogger follows this stack overflow post: https://stackoverflow.com/a/52923899/15410622

Types

type BlogPost

type BlogPost struct {
	Title       string `yaml:"title"`
	Description string `yaml:"description"`
	Content     string
}

type Config

type Config struct {
	Port         int
	Address      string
	Profile      bool
	TrackingCode string
	CorsDomain   string
	PullOrigin   string
	FeatureFlags FeatureFlags
	Deprecated   Deprecated
	Hidden       HiddenArgs
}

func (*Config) HandleDeprecated

func (config *Config) HandleDeprecated()

type Deprecated

type Deprecated struct {
	FeatureFlags struct {
		Blog bool
	}
}

type FeatureFlags

type FeatureFlags []string

func (*FeatureFlags) Contains

func (f *FeatureFlags) Contains(key string) bool

Contains reports wheter a key is contained within the FeatureFlags slice. It returns true if the key is in the slice, else false.

type HiddenArgs

type HiddenArgs struct {
	Development bool
}

type Profile

type Profile struct {
	IconClass   string
	Description string
	URL         string
}

type ResourceType

type ResourceType int
const (
	CSS ResourceType = iota
	JS
	Image
)

type RessourcesWithSri

type RessourcesWithSri struct {
	Path string
	Sri  string
	Type ResourceType
}

Source Files

  • deprecatedCliHandler.go
  • subresourceIntegrity.go
  • types.go
  • utils.go

Jump to

Keyboard shortcuts

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