Documentation
¶
Overview ¶
Package util contains multiple utils for Fish
Index ¶
- Constants
- func Contains(list []string, value string) bool
- func CreateLock(lockPath string) error
- func DotSerialize(prefix string, in any) map[string]string
- func ExpressionSQLFilter(filter string) (string, error)
- func FileCopy(src string, dst string) error
- func FileReplaceBlock(path, blockFrom, blockTo string, lines ...string) error
- func FileReplaceToken(path string, fullLine, add, anycase bool, tokenValues ...string) error
- func FileStartsWith(path string, prefix []byte) error
- func SerializeMetadata(format, prefix string, data map[string]any) (out []byte, err error)
- func WaitLock(lockPath string, clean func()) error
- type Duration
- type HumanSize
- type PassThruMonitor
- type StreamLogMonitor
- type UnparsedJSON
Constants ¶
const ( B HumanSize = 1 KB = B << 10 MB = KB << 10 GB = MB << 10 TB = GB << 10 PB = TB << 10 EB = PB << 10 )
Definitions of different byte sizes and some maximums
Variables ¶
This section is empty.
Functions ¶
func CreateLock ¶
CreateLock creates the lock file, notice - remove it yourself
func DotSerialize ¶
DotSerialize serializes data to get map as key.subkey=value with dot separation for the keys
func ExpressionSQLFilter ¶ added in v0.7.5
ExpressionSQLFilter ensures the where filter doesn't contain bad things (SQL injections) and returns a good one could be used as Where() in gorm. It expects just an expression, so no other SQL keys will work here. For example: * `id=1 AND a in (1,2) ORDER BY i; DROP u;` will become just `"id" = 1 AND "a" IN (1, 2)` * `DROP users` - will fail * `id = 1 OR lol in (SELECT * FROM users)` - will fail
func FileReplaceBlock ¶
FileReplaceBlock is a simple block replace in the file
func FileReplaceToken ¶
FileReplaceToken simple replaces tocken in the file
func FileStartsWith ¶
FileStartsWith checks the file starts with required prefix
func SerializeMetadata ¶
SerializeMetadata serializes dictionary to usable format
Types ¶
type Duration ¶ added in v0.7.3
Duration is a simple wrapper to add serialization functions
func (Duration) MarshalJSON ¶ added in v0.7.3
MarshalJSON represents Duration as JSON string
func (*Duration) UnmarshalJSON ¶ added in v0.7.3
UnmarshalJSON parses JSON string as Duration
type HumanSize ¶ added in v0.7.5
type HumanSize uint64
HumanSize describes data size In Human Form
func NewHumanSize ¶ added in v0.7.5
NewHumanSize creates human size for you
func (HumanSize) MarshalText ¶ added in v0.7.5
MarshalText represents HumanSize as string
func (*HumanSize) UnmarshalText ¶ added in v0.7.5
UnmarshalText converts text to HumanSize number To be properly parsed the text should contain number and unit ("B", "KB", "MB"...) in the end
type PassThruMonitor ¶
type PassThruMonitor struct {
io.Reader
Name string // Prefix for the message
Length int64 // Expected length
// contains filtered or unexported fields
}
PassThruMonitor wraps an existing io.Reader to monitor the stream
It simply forwards the Read() call, while displaying the results from individual calls to it.
type StreamLogMonitor ¶ added in v0.7.2
type StreamLogMonitor struct {
Prefix string // Prefix for the line
// contains filtered or unexported fields
}
StreamLogMonitor wraps an existing io.Reader to monitor the log stream and adds prefix before each line
type UnparsedJSON ¶ added in v0.7.5
type UnparsedJSON string
UnparsedJSON is used to store json as is and not parse it until the right time
func (UnparsedJSON) MarshalJSON ¶ added in v0.7.5
func (r UnparsedJSON) MarshalJSON() ([]byte, error)
MarshalJSON represents UnparsedJson as bytes
func (*UnparsedJSON) UnmarshalJSON ¶ added in v0.7.5
func (r *UnparsedJSON) UnmarshalJSON(b []byte) error
UnmarshalJSON converts bytes to UnparsedJson
func (*UnparsedJSON) UnmarshalYAML ¶ added in v0.7.5
func (r *UnparsedJSON) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML is needed to properly convert incoming yaml requests into json