README

Utils

Release Discord Test Security Linter

A collection of common functions but with better performance, less allocations and no dependencies created for Fiber.

// go test -v -benchmem -run=^$ -bench=Benchmark_ -count=2

Benchmark_GetMIME/fiber               14287550                84.2 ns/op             0 B/op          0 allocs/op
Benchmark_GetMIME/fiber               14819698                78.3 ns/op             0 B/op          0 allocs/op
Benchmark_GetMIME/default              6459128                 184 ns/op             0 B/op          0 allocs/op
Benchmark_GetMIME/default              6385042                 184 ns/op             0 B/op          0 allocs/op

Benchmark_UUID/fiber                  17652744                59.1 ns/op            48 B/op          1 allocs/op
Benchmark_UUID/fiber                  19361145                58.5 ns/op            48 B/op          1 allocs/op
Benchmark_UUID/default                 4271024                 281 ns/op            64 B/op          2 allocs/op
Benchmark_UUID/default                 4435306                 278 ns/op            64 B/op          2 allocs/op

Benchmark_ToLower/fiber               22987184                48.2 ns/op            48 B/op          1 allocs/op
Benchmark_ToLower/fiber               24491794                49.6 ns/op            48 B/op          1 allocs/op
Benchmark_ToLower/default              9232608                 123 ns/op            48 B/op          1 allocs/op
Benchmark_ToLower/default              9454870                 123 ns/op            48 B/op          1 allocs/op

Benchmark_ToLowerBytes/fiber          44463876                26.1 ns/op             0 B/op          0 allocs/op
Benchmark_ToLowerBytes/fiber          39997200                26.1 ns/op             0 B/op          0 allocs/op
Benchmark_ToLowerBytes/default        14879088                77.6 ns/op            48 B/op          1 allocs/op
Benchmark_ToLowerBytes/default        14631433                79.2 ns/op            48 B/op          1 allocs/op

Benchmark_ToUpper/fiber               22648730                49.4 ns/op            48 B/op          1 allocs/op
Benchmark_ToUpper/fiber               23084425                48.6 ns/op            48 B/op          1 allocs/op
Benchmark_ToUpper/default              9520122                 124 ns/op            48 B/op          1 allocs/op
Benchmark_ToUpper/default              9375014                 133 ns/op            48 B/op          1 allocs/op

Benchmark_ToUpperBytes/fiber          44439176                25.6 ns/op             0 B/op          0 allocs/op
Benchmark_ToUpperBytes/fiber          44458934                25.5 ns/op             0 B/op          0 allocs/op
Benchmark_ToUpperBytes/default        15347073                74.1 ns/op            48 B/op          1 allocs/op
Benchmark_ToUpperBytes/default        15511370                74.2 ns/op            48 B/op          1 allocs/op

Benchmark_EqualFolds/fiber            34297864                33.8 ns/op             0 B/op          0 allocs/op
Benchmark_EqualFolds/fiber            34285322                34.0 ns/op             0 B/op          0 allocs/op
Benchmark_EqualFolds/default          12756945                91.8 ns/op             0 B/op          0 allocs/op
Benchmark_EqualFolds/default          13015282                91.1 ns/op             0 B/op          0 allocs/op

Benchmark_Trim/fiber                  207314002               5.85 ns/op             0 B/op          0 allocs/op
Benchmark_Trim/fiber                  207386125               5.78 ns/op             0 B/op          0 allocs/op
Benchmark_Trim/default                16506302                68.5 ns/op            32 B/op          1 allocs/op
Benchmark_Trim/default                16669119                68.9 ns/op            32 B/op          1 allocs/op

Benchmark_TrimLeft/fiber              343254828               3.47 ns/op             0 B/op          0 allocs/op
Benchmark_TrimLeft/fiber              344407171               3.45 ns/op             0 B/op          0 allocs/op
Benchmark_TrimLeft/default            24999790                46.4 ns/op            32 B/op          1 allocs/op
Benchmark_TrimLeft/default            25001926                45.3 ns/op            32 B/op          1 allocs/op

Benchmark_TrimRight/fiber             374543056               3.15 ns/op             0 B/op          0 allocs/op
Benchmark_TrimRight/fiber             336067616               3.15 ns/op             0 B/op          0 allocs/op
Benchmark_TrimRight/default           20868186                52.8 ns/op            32 B/op          1 allocs/op
Benchmark_TrimRight/default           21434695                55.1 ns/op            32 B/op          1 allocs/op
Expand ▾ Collapse ▴

Documentation

Index

Constants

View Source
const MIMEOctetStream = "application/octet-stream"

Variables

This section is empty.

Functions

func AssertEqual

func AssertEqual(t testing.TB, expected interface{}, actual interface{}, description ...string)

    AssertEqual checks if values are equal

    func EqualsFold

    func EqualsFold(b, s []byte) (equals bool)

      EqualFold the equivalent of bytes.EqualFold

      func FunctionName

      func FunctionName(fn interface{}) string

        Returns function name

        func GetBytes

        func GetBytes(s string) (bs []byte)

          #nosec G103 GetBytes returns a byte pointer without allocation

          func GetCharPos

          func GetCharPos(s string, char byte, matchCount int) int

            GetCharPos ...

            func GetMIME

            func GetMIME(extension string) (mime string)

              GetMIME returns the content-type of a file extension

              func GetString

              func GetString(b []byte) string

                #nosec G103 GetString returns a string pointer without allocation

                func GetTrimmedParam

                func GetTrimmedParam(param string) string

                  GetTrimmedParam trims the ':' & '?' from a string

                  func ImmutableString

                  func ImmutableString(s string) string

                    ImmutableString copies a string to make it immutable

                    func StatusMessage

                    func StatusMessage(status int) string

                      StatusMessage returns the correct message for the provided HTTP statuscode

                      func ToLower

                      func ToLower(b string) string

                        ToLower is the equivalent of strings.ToLower

                        func ToLowerBytes

                        func ToLowerBytes(b []byte) []byte

                          ToLowerBytes is the equivalent of bytes.ToLower

                          func ToUpper

                          func ToUpper(b string) string

                            ToUpper is the equivalent of strings.ToUpper

                            func ToUpperBytes

                            func ToUpperBytes(b []byte) []byte

                              ToUpperBytes is the equivalent of bytes.ToUpper

                              func Trim

                              func Trim(s string, cutset byte) string

                                Trim is the equivalent of strings.Trim

                                func TrimBytes

                                func TrimBytes(b []byte, cutset byte) []byte

                                  TrimBytes is the equivalent of bytes.Trim

                                  func TrimLeft

                                  func TrimLeft(s string, cutset byte) string

                                    TrimLeft is the equivalent of strings.TrimLeft

                                    func TrimLeftBytes

                                    func TrimLeftBytes(b []byte, cutset byte) []byte

                                      TrimLeftBytes is the equivalent of bytes.TrimLeft

                                      func TrimRight

                                      func TrimRight(s string, cutset byte) string

                                        TrimRight is the equivalent of strings.TrimRight

                                        func TrimRightBytes

                                        func TrimRightBytes(b []byte, cutset byte) []byte

                                          TrimRightBytes is the equivalent of bytes.TrimRight

                                          func UUID

                                          func UUID() string

                                          Types

                                          This section is empty.

                                          Source Files

                                          Directories

                                          Path Synopsis
                                          encoding
                                          Package fasttemplate implements simple and fast template library.
                                          Package fasttemplate implements simple and fast template library.
                                          Package gorilla/schema fills a struct with form values.
                                          Package gorilla/schema fills a struct with form values.