Help us shape the future of Go! Take the 2026 Go Developer Survey

utils

package module
v2.6.3 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 34 Imported by: 136

README

Fiber Utils Fiber Utils

Fiber Utils

Release Test Codecov Linter Benchmarks Discord

A collection of common functions for Fiber with better performance, fewer allocations, and fewer dependencies.

Benchmarks

Per-commit benchmark charts: https://gofiber.github.io/utils/benchmarks/

Each table below starts with the go test command that produced it. Maintainers refresh the numbers with make benchupdate, or by commenting /bench-readme (arm64) or /bench-readme-amd64 on a pull request.

Environment: goos: darwin goarch: arm64 pkg: github.com/gofiber/utils/v2 cpu: Apple M2 Pro

// go test ./... -benchmem -run=^$ -bench=Benchmark_ -count=1
// (swar's Benchmark_Load8_Fusion, an advisory codegen guard, is deliberately omitted)

# Case Conversion
Benchmark_ToLowerBytes/empty/fiber-12                              599341221    1.970  ns/op     0  B/op   0  allocs/op
Benchmark_ToLowerBytes/empty/fiber/unsafe-12                       613673802    1.951  ns/op     0  B/op   0  allocs/op
Benchmark_ToLowerBytes/empty/default-12                            363300402    3.316  ns/op     0  B/op   0  allocs/op
Benchmark_ToLowerBytes/http-get/fiber-12                           350302147    3.434  ns/op     0  B/op   0  allocs/op
Benchmark_ToLowerBytes/http-get/fiber/unsafe-12                    250488015    4.803  ns/op     0  B/op   0  allocs/op
Benchmark_ToLowerBytes/http-get/default-12                          65883986    18.03  ns/op     8  B/op   1  allocs/op
Benchmark_ToLowerBytes/http-get-upper/fiber-12                      95234625    12.53  ns/op     3  B/op   1  allocs/op
Benchmark_ToLowerBytes/http-get-upper/fiber/unsafe-12              242418936    4.802  ns/op     0  B/op   0  allocs/op
Benchmark_ToLowerBytes/http-get-upper/default-12                    86405012    13.85  ns/op     8  B/op   1  allocs/op
Benchmark_ToLowerBytes/header-content-type-mixed/fiber-12           52263289    22.74  ns/op    48  B/op   1  allocs/op
Benchmark_ToLowerBytes/header-content-type-mixed/fiber/unsafe-12   131711175    9.101  ns/op     0  B/op   0  allocs/op
Benchmark_ToLowerBytes/header-content-type-mixed/default-12         25312339    47.13  ns/op    48  B/op   1  allocs/op
Benchmark_ToLowerBytes/large-lower/fiber-12                        120148472    10.02  ns/op     0  B/op   0  allocs/op
Benchmark_ToLowerBytes/large-lower/fiber/unsafe-12                 100000000    10.57  ns/op     0  B/op   0  allocs/op
Benchmark_ToLowerBytes/large-lower/default-12                       16746064    71.43  ns/op    64  B/op   1  allocs/op
Benchmark_ToLowerBytes/large-upper/fiber-12                         46270634    26.82  ns/op    64  B/op   1  allocs/op
Benchmark_ToLowerBytes/large-upper/fiber/unsafe-12                 100000000    10.71  ns/op     0  B/op   0  allocs/op
Benchmark_ToLowerBytes/large-upper/default-12                       15734505    76.92  ns/op    64  B/op   1  allocs/op
Benchmark_ToLowerBytes/large-mixed/fiber-12                         46607823    26.06  ns/op    64  B/op   1  allocs/op
Benchmark_ToLowerBytes/large-mixed/fiber/unsafe-12                 100000000    10.86  ns/op     0  B/op   0  allocs/op
Benchmark_ToLowerBytes/large-mixed/default-12                       16291084    73.76  ns/op    64  B/op   1  allocs/op
Benchmark_ToUpperBytes/empty/fiber-12                              607678140    1.976  ns/op     0  B/op   0  allocs/op
Benchmark_ToUpperBytes/empty/fiber/unsafe-12                       611928006    1.981  ns/op     0  B/op   0  allocs/op
Benchmark_ToUpperBytes/empty/default-12                            362632894    3.309  ns/op     0  B/op   0  allocs/op
Benchmark_ToUpperBytes/http-get/fiber-12                            95358867    12.55  ns/op     3  B/op   1  allocs/op
Benchmark_ToUpperBytes/http-get/fiber/unsafe-12                    249490471    4.905  ns/op     0  B/op   0  allocs/op
Benchmark_ToUpperBytes/http-get/default-12                          79248020    14.63  ns/op     8  B/op   1  allocs/op
Benchmark_ToUpperBytes/http-get-upper/fiber-12                     365516280    3.330  ns/op     0  B/op   0  allocs/op
Benchmark_ToUpperBytes/http-get-upper/fiber/unsafe-12              249981619    4.803  ns/op     0  B/op   0  allocs/op
Benchmark_ToUpperBytes/http-get-upper/default-12                    64343162    19.01  ns/op     8  B/op   1  allocs/op
Benchmark_ToUpperBytes/header-content-type-mixed/fiber-12           52506741    22.69  ns/op    48  B/op   1  allocs/op
Benchmark_ToUpperBytes/header-content-type-mixed/fiber/unsafe-12   130478352    9.350  ns/op     0  B/op   0  allocs/op
Benchmark_ToUpperBytes/header-content-type-mixed/default-12         22415607    54.44  ns/op    48  B/op   1  allocs/op
Benchmark_ToUpperBytes/large-lower/fiber-12                         44765679    26.92  ns/op    64  B/op   1  allocs/op
Benchmark_ToUpperBytes/large-lower/fiber/unsafe-12                 100000000    13.68  ns/op     0  B/op   0  allocs/op
Benchmark_ToUpperBytes/large-lower/default-12                       14464340    110.7  ns/op    64  B/op   1  allocs/op
Benchmark_ToUpperBytes/large-upper/fiber-12                        100000000    11.98  ns/op     0  B/op   0  allocs/op
Benchmark_ToUpperBytes/large-upper/fiber/unsafe-12                  83808488    13.94  ns/op     0  B/op   0  allocs/op
Benchmark_ToUpperBytes/large-upper/default-12                       13142096    87.35  ns/op    64  B/op   1  allocs/op
Benchmark_ToUpperBytes/large-mixed/fiber-12                         33038661    32.75  ns/op    64  B/op   1  allocs/op
Benchmark_ToUpperBytes/large-mixed/fiber/unsafe-12                 100000000    10.93  ns/op     0  B/op   0  allocs/op
Benchmark_ToUpperBytes/large-mixed/default-12                       15034422    98.27  ns/op    64  B/op   1  allocs/op
Benchmark_ToUpper/empty/fiber-12                                   595298628    2.309  ns/op     0  B/op   0  allocs/op
Benchmark_ToUpper/empty/fiber/unsafe-12                            595273404    2.021  ns/op     0  B/op   0  allocs/op
Benchmark_ToUpper/empty/default-12                                 636980288    1.883  ns/op     0  B/op   0  allocs/op
Benchmark_ToUpper/http-get/fiber-12                                 97025577    12.40  ns/op     3  B/op   1  allocs/op
Benchmark_ToUpper/http-get/fiber/unsafe-12                         244711635    4.857  ns/op     0  B/op   0  allocs/op
Benchmark_ToUpper/http-get/default-12                               59790234    19.54  ns/op     8  B/op   1  allocs/op
Benchmark_ToUpper/http-get-upper/fiber-12                          383218539    3.056  ns/op     0  B/op   0  allocs/op
Benchmark_ToUpper/http-get-upper/fiber/unsafe-12                   247851331    4.864  ns/op     0  B/op   0  allocs/op
Benchmark_ToUpper/http-get-upper/default-12                        223044249    5.182  ns/op     0  B/op   0  allocs/op
Benchmark_ToUpper/header-content-type-mixed/fiber-12                52628502    24.13  ns/op    48  B/op   1  allocs/op
Benchmark_ToUpper/header-content-type-mixed/fiber/unsafe-12        127726341    9.233  ns/op     0  B/op   0  allocs/op
Benchmark_ToUpper/header-content-type-mixed/default-12              11549816    104.0  ns/op    48  B/op   1  allocs/op
Benchmark_ToUpper/large-lower/fiber-12                              42409070    26.04  ns/op    64  B/op   1  allocs/op
Benchmark_ToUpper/large-lower/fiber/unsafe-12                      100000000    11.00  ns/op     0  B/op   0  allocs/op
Benchmark_ToUpper/large-lower/default-12                             7051911    169.0  ns/op    64  B/op   1  allocs/op
Benchmark_ToUpper/large-upper/fiber-12                             123837582    9.590  ns/op     0  B/op   0  allocs/op
Benchmark_ToUpper/large-upper/fiber/unsafe-12                      100000000    10.83  ns/op     0  B/op   0  allocs/op
Benchmark_ToUpper/large-upper/default-12                            19115356    61.51  ns/op     0  B/op   0  allocs/op
Benchmark_ToUpper/large-mixed/fiber-12                              45872143    27.77  ns/op    64  B/op   1  allocs/op
Benchmark_ToUpper/large-mixed/fiber/unsafe-12                      100000000    11.00  ns/op     0  B/op   0  allocs/op
Benchmark_ToUpper/large-mixed/default-12                             5927710    203.1  ns/op    64  B/op   1  allocs/op
Benchmark_ToLower/empty/fiber-12                                   613625554    1.952  ns/op     0  B/op   0  allocs/op
Benchmark_ToLower/empty/fiber/unsafe-12                            572670608    1.989  ns/op     0  B/op   0  allocs/op
Benchmark_ToLower/empty/default-12                                 644769141    1.863  ns/op     0  B/op   0  allocs/op
Benchmark_ToLower/http-get/fiber-12                                395302272    3.034  ns/op     0  B/op   0  allocs/op
Benchmark_ToLower/http-get/fiber/unsafe-12                         252231990    4.813  ns/op     0  B/op   0  allocs/op
Benchmark_ToLower/http-get/default-12                              284202345    4.219  ns/op     0  B/op   0  allocs/op
Benchmark_ToLower/http-get-upper/fiber-12                          100000000    12.08  ns/op     3  B/op   1  allocs/op
Benchmark_ToLower/http-get-upper/fiber/unsafe-12                   252859507    4.816  ns/op     0  B/op   0  allocs/op
Benchmark_ToLower/http-get-upper/default-12                         60415860    19.54  ns/op     8  B/op   1  allocs/op
Benchmark_ToLower/header-content-type-mixed/fiber-12                53446660    22.49  ns/op    48  B/op   1  allocs/op
Benchmark_ToLower/header-content-type-mixed/fiber/unsafe-12        131152108    9.153  ns/op     0  B/op   0  allocs/op
Benchmark_ToLower/header-content-type-mixed/default-12              18039788    66.79  ns/op    48  B/op   1  allocs/op
Benchmark_ToLower/large-lower/fiber-12                             120227584    9.982  ns/op     0  B/op   0  allocs/op
Benchmark_ToLower/large-lower/fiber/unsafe-12                      100000000    10.68  ns/op     0  B/op   0  allocs/op
Benchmark_ToLower/large-lower/default-12                            24070928    48.79  ns/op     0  B/op   0  allocs/op
Benchmark_ToLower/large-upper/fiber-12                              44699118    25.92  ns/op    64  B/op   1  allocs/op
Benchmark_ToLower/large-upper/fiber/unsafe-12                      100000000    10.74  ns/op     0  B/op   0  allocs/op
Benchmark_ToLower/large-upper/default-12                             7075200    170.0  ns/op    64  B/op   1  allocs/op
Benchmark_ToLower/large-mixed/fiber-12                              46426453    26.01  ns/op    64  B/op   1  allocs/op
Benchmark_ToLower/large-mixed/fiber/unsafe-12                      100000000    10.74  ns/op     0  B/op   0  allocs/op
Benchmark_ToLower/large-mixed/default-12                             5682778    204.3  ns/op    64  B/op   1  allocs/op

# Add Trailing Slash
Benchmark_AddTrailingSlashBytes/empty-12                          1000000000   0.5857  ns/op     0  B/op   0  allocs/op
Benchmark_AddTrailingSlashBytes/slash-only-12                     1000000000   0.8694  ns/op     0  B/op   0  allocs/op
Benchmark_AddTrailingSlashBytes/short-no-slash-12                  100000000    11.65  ns/op     4  B/op   1  allocs/op
Benchmark_AddTrailingSlashBytes/short-with-slash-12               1000000000   0.8867  ns/op     0  B/op   0  allocs/op
Benchmark_AddTrailingSlashBytes/path-no-slash-12                    93543546    13.36  ns/op    16  B/op   1  allocs/op
Benchmark_AddTrailingSlashBytes/path-with-slash-12                1000000000   0.9011  ns/op     0  B/op   0  allocs/op
Benchmark_AddTrailingSlashString/empty-12                         1000000000   0.2926  ns/op     0  B/op   0  allocs/op
Benchmark_AddTrailingSlashString/slash-only-12                    1000000000   0.4482  ns/op     0  B/op   0  allocs/op
Benchmark_AddTrailingSlashString/short-no-slash-12                 100000000    11.37  ns/op     4  B/op   1  allocs/op
Benchmark_AddTrailingSlashString/short-with-slash-12              1000000000   0.4502  ns/op     0  B/op   0  allocs/op
Benchmark_AddTrailingSlashString/path-no-slash-12                   82427726    14.41  ns/op    16  B/op   1  allocs/op
Benchmark_AddTrailingSlashString/path-with-slash-12               1000000000   0.4529  ns/op     0  B/op   0  allocs/op

# EqualFold
Benchmark_EqualFoldBytes/fiber-12                                   67368261    18.48  ns/op     0  B/op   0  allocs/op
Benchmark_EqualFoldBytes/default-12                                 17774803    65.91  ns/op     0  B/op   0  allocs/op
Benchmark_EqualFold/fiber-12                                        80501566    14.75  ns/op     0  B/op   0  allocs/op
Benchmark_EqualFold/default-12                                      18314365    65.96  ns/op     0  B/op   0  allocs/op

# Search
// amd64 note: IndexAny2/IndexAny3 dispatch to package simd for 32+ byte
// inputs; these arm64 rows keep the portable SWAR path. For amd64 numbers
// see the Benchmark_Memchr2/Benchmark_Memchr3 rows in the simd section
// below (the kernels these functions dispatch to).
Benchmark_IndexAny2/7B/swar-12                                     282163779    4.297  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny2/7B/scalar-12                                   314553402    3.826  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny2/7B/stdlib-indexany-12                           50085909    23.97  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny2/8B/swar-12                                     522780714    2.289  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny2/8B/scalar-12                                   271494799    4.206  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny2/8B/stdlib-indexany-12                           44831599    26.78  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny2/16B/swar-12                                    393245086    3.047  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny2/16B/scalar-12                                  168476984    7.117  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny2/16B/stdlib-indexany-12                         100000000    10.03  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny2/32B/swar-12                                    252199587    4.802  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny2/32B/scalar-12                                   84105762    14.27  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny2/32B/stdlib-indexany-12                          70291048    17.37  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny2/64B/swar-12                                    144335962    8.290  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny2/64B/scalar-12                                   42694686    28.60  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny2/64B/stdlib-indexany-12                          37615540    32.23  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny2/512B/swar-12                                    20231538    59.71  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny2/512B/scalar-12                                   5071586    233.6  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny2/512B/stdlib-indexany-12                          4448119    274.2  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny3/7B/swar-12                                     221889592    5.397  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny3/7B/scalar-12                                   240859849    4.977  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny3/8B/swar-12                                     445742876    2.689  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny3/8B/scalar-12                                   211981612    5.620  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny3/16B/swar-12                                    326475568    3.739  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny3/16B/scalar-12                                  100000000    10.31  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny3/32B/swar-12                                    196365920    6.112  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny3/32B/scalar-12                                   60021255    19.81  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny3/64B/swar-12                                    100000000    10.98  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny3/64B/scalar-12                                   31180405    38.97  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny3/512B/swar-12                                    15466316    79.22  ns/op     0  B/op   0  allocs/op
Benchmark_IndexAny3/512B/scalar-12                                   3911382    307.1  ns/op     0  B/op   0  allocs/op
Benchmark_IndexFold/miss-8B/swar-12                                332497509    3.634  ns/op     0  B/op   0  allocs/op
Benchmark_IndexFold/miss-8B/scalar-12                              491493494    2.408  ns/op     0  B/op   0  allocs/op
Benchmark_IndexFold/miss-32B/swar-12                               149769112    7.928  ns/op     0  B/op   0  allocs/op
Benchmark_IndexFold/miss-32B/scalar-12                              44041342    27.13  ns/op     0  B/op   0  allocs/op
Benchmark_IndexFold/hit-32B/swar-12                                138732252    8.758  ns/op     0  B/op   0  allocs/op
Benchmark_IndexFold/hit-32B/scalar-12                               33871633    30.73  ns/op     0  B/op   0  allocs/op
Benchmark_IndexFold/hit-tail/swar-12                               100000000    12.34  ns/op     0  B/op   0  allocs/op
Benchmark_IndexFold/hit-tail/scalar-12                              16138168    75.39  ns/op     0  B/op   0  allocs/op
Benchmark_IndexFold/miss-64B/swar-12                               100000000    11.37  ns/op     0  B/op   0  allocs/op
Benchmark_IndexFold/miss-64B/scalar-12                              17902330    67.78  ns/op     0  B/op   0  allocs/op
Benchmark_IndexFold/miss-512B/swar-12                               17640939    67.65  ns/op     0  B/op   0  allocs/op
Benchmark_IndexFold/miss-512B/scalar-12                              2211582    544.4  ns/op     0  B/op   0  allocs/op
Benchmark_IndexFold/long-hit-64B/swar-12                           100000000    11.58  ns/op     0  B/op   0  allocs/op
Benchmark_IndexFold/long-hit-64B/scalar-12                          23906326    51.33  ns/op     0  B/op   0  allocs/op
Benchmark_IndexFold/long-miss-64B/swar-12                          100000000    11.33  ns/op     0  B/op   0  allocs/op
Benchmark_IndexFold/long-miss-64B/scalar-12                         23553600    50.27  ns/op     0  B/op   0  allocs/op

# ASCII
// amd64 note: IsASCII dispatches to package simd for 32+ byte inputs;
// these arm64 rows keep the portable SWAR path. See the simd section
// below for amd64 numbers.
Benchmark_IsASCII/7B/swar-12                                       238699563    5.001  ns/op     0  B/op   0  allocs/op
Benchmark_IsASCII/7B/scalar-12                                     292669958    4.064  ns/op     0  B/op   0  allocs/op
Benchmark_IsASCII/8B/swar-12                                       439961722    2.687  ns/op     0  B/op   0  allocs/op
Benchmark_IsASCII/8B/scalar-12                                     274732192    4.364  ns/op     0  B/op   0  allocs/op
Benchmark_IsASCII/16B/swar-12                                      367179319    3.255  ns/op     0  B/op   0  allocs/op
Benchmark_IsASCII/16B/scalar-12                                    179331987    6.706  ns/op     0  B/op   0  allocs/op
Benchmark_IsASCII/32B/swar-12                                      368345228    3.271  ns/op     0  B/op   0  allocs/op
Benchmark_IsASCII/32B/scalar-12                                    100000000    11.62  ns/op     0  B/op   0  allocs/op
Benchmark_IsASCII/64B/swar-12                                      265505815    4.486  ns/op     0  B/op   0  allocs/op
Benchmark_IsASCII/64B/scalar-12                                     57864440    21.33  ns/op     0  B/op   0  allocs/op
Benchmark_IsASCII/512B/swar-12                                      47664915    25.14  ns/op     0  B/op   0  allocs/op
Benchmark_IsASCII/512B/scalar-12                                     7081790    169.5  ns/op     0  B/op   0  allocs/op
Benchmark_IndexNonQuotable/7B/swar-12                              142234436    8.424  ns/op     0  B/op   0  allocs/op
Benchmark_IndexNonQuotable/7B/scalar-12                            142394628    8.174  ns/op     0  B/op   0  allocs/op
Benchmark_IndexNonQuotable/8B/swar-12                              401721262    3.099  ns/op     0  B/op   0  allocs/op
Benchmark_IndexNonQuotable/8B/scalar-12                            138047568    8.654  ns/op     0  B/op   0  allocs/op
Benchmark_IndexNonQuotable/16B/swar-12                             244592613    5.059  ns/op     0  B/op   0  allocs/op
Benchmark_IndexNonQuotable/16B/scalar-12                            75413396    15.94  ns/op     0  B/op   0  allocs/op
Benchmark_IndexNonQuotable/32B/swar-12                             138857455    8.875  ns/op     0  B/op   0  allocs/op
Benchmark_IndexNonQuotable/32B/scalar-12                            39539425    30.18  ns/op     0  B/op   0  allocs/op
Benchmark_IndexNonQuotable/64B/swar-12                              75193269    16.46  ns/op     0  B/op   0  allocs/op
Benchmark_IndexNonQuotable/64B/scalar-12                            20898807    57.81  ns/op     0  B/op   0  allocs/op
Benchmark_IndexNonQuotable/512B/swar-12                              9634008    124.9  ns/op     0  B/op   0  allocs/op
Benchmark_IndexNonQuotable/512B/scalar-12                            2619062    460.6  ns/op     0  B/op   0  allocs/op

# Trim
Benchmark_TrimRight/fiber-12                                       587360972    2.043  ns/op     0  B/op   0  allocs/op
Benchmark_TrimRight/default-12                                     417142952    2.887  ns/op     0  B/op   0  allocs/op
Benchmark_TrimRightBytes/fiber-12                                  590828253    2.067  ns/op     0  B/op   0  allocs/op
Benchmark_TrimRightBytes/default-12                                374548395    3.236  ns/op     0  B/op   0  allocs/op
Benchmark_TrimLeft/fiber-12                                        590822072    2.030  ns/op     0  B/op   0  allocs/op
Benchmark_TrimLeft/default-12                                      408184784    2.967  ns/op     0  B/op   0  allocs/op
Benchmark_TrimLeftBytes/fiber-12                                   592875732    2.033  ns/op     0  B/op   0  allocs/op
Benchmark_TrimLeftBytes/default-12                                 405921434    2.967  ns/op     0  B/op   0  allocs/op
Benchmark_Trim/fiber-12                                            317625432    3.758  ns/op     0  B/op   0  allocs/op
Benchmark_Trim/default-12                                          250173384    4.735  ns/op     0  B/op   0  allocs/op
Benchmark_Trim/default.trimspace-12                                241883282    5.022  ns/op     0  B/op   0  allocs/op
Benchmark_TrimBytes/fiber-12                                       308885211    3.858  ns/op     0  B/op   0  allocs/op
Benchmark_TrimBytes/default-12                                     254064188    4.802  ns/op     0  B/op   0  allocs/op
Benchmark_TrimBytes/default.trimspace-12                           224231778    5.330  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpace/fiber/empty-12                                1000000000   0.3017  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpace/default/empty-12                               583064172    2.074  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpace/fiber/spaces-12                                387354229    3.059  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpace/default/spaces-12                              320059388    3.651  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpace/fiber/ascii-word-12                            345078337    3.535  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpace/default/ascii-word-12                          270603267    4.465  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpace/fiber/auth-header-bearer-12                    291494109    4.141  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpace/default/auth-header-bearer-12                  224087944    5.329  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpace/fiber/auth-header-basic-12                     390765345    3.047  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpace/default/auth-header-basic-12                   258943531    4.718  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpace/fiber/accept-encoding-12                       344369745    3.490  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpace/default/accept-encoding-12                     277203638    4.347  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpace/fiber/content-type-12                          344263705    3.506  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpace/default/content-type-12                        276213367    4.343  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpace/fiber/x-forwarded-for-12                       460119685    2.653  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpace/default/x-forwarded-for-12                     296468840    4.058  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpace/fiber/query-params-12                          330053276    3.520  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpace/default/query-params-12                        275688495    4.352  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpace/fiber/ascii-long-12                            275511898    4.342  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpace/default/ascii-long-12                          206143018    5.807  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpace/fiber/no-trim-12                              1000000000   0.5914  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpace/default/no-trim-12                             451842741    2.634  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpace/fiber/mixed-whitespace-12                      296083767    4.054  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpace/default/mixed-whitespace-12                    224007750    5.294  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpaceBytes/fiber/empty-12                           1000000000   0.2914  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpaceBytes/default/empty-12                          519488766    2.352  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpaceBytes/fiber/spaces-12                           410959255    2.966  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpaceBytes/default/spaces-12                         315602949    3.827  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpaceBytes/fiber/ascii-word-12                       341217429    3.519  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpaceBytes/default/ascii-word-12                     247799318    4.667  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpaceBytes/fiber/auth-header-bearer-12               295130076    4.182  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpaceBytes/default/auth-header-bearer-12             209162235    5.685  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpaceBytes/fiber/auth-header-basic-12                393366796    3.053  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpaceBytes/default/auth-header-basic-12              240882009    4.930  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpaceBytes/fiber/accept-encoding-12                  343673244    3.512  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpaceBytes/default/accept-encoding-12                250962042    4.642  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpaceBytes/fiber/content-type-12                     344382758    3.516  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpaceBytes/default/content-type-12                   250622116    4.693  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpaceBytes/fiber/x-forwarded-for-12                  459435145    2.621  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpaceBytes/default/x-forwarded-for-12                276595178    4.359  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpaceBytes/fiber/query-params-12                     341144192    3.526  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpaceBytes/default/query-params-12                   255843174    4.873  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpaceBytes/fiber/ascii-long-12                       270183530    4.445  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpaceBytes/default/ascii-long-12                     189740618    6.335  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpaceBytes/fiber/no-trim-12                         1000000000   0.5969  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpaceBytes/default/no-trim-12                        406072189    2.941  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpaceBytes/fiber/mixed-whitespace-12                 289382116    4.057  ns/op     0  B/op   0  allocs/op
Benchmark_TrimSpaceBytes/default/mixed-whitespace-12               218559462    5.493  ns/op     0  B/op   0  allocs/op

# Convert
Benchmark_ConvertToBytes/fiber-12                                  320332576    3.787  ns/op     0  B/op   0  allocs/op
Benchmark_ToString/int-12                                          499429904    2.382  ns/op     0  B/op   0  allocs/op
Benchmark_ToString/int8-12                                         614406423    1.965  ns/op     0  B/op   0  allocs/op
Benchmark_ToString/int16-12                                        486644316    2.463  ns/op     0  B/op   0  allocs/op
Benchmark_ToString/int32-12                                        495227163    2.422  ns/op     0  B/op   0  allocs/op
Benchmark_ToString/int64-12                                        502362236    2.429  ns/op     0  B/op   0  allocs/op
Benchmark_ToString/uint-12                                         561693333    2.101  ns/op     0  B/op   0  allocs/op
Benchmark_ToString/uint8-12                                        611239028    1.965  ns/op     0  B/op   0  allocs/op
Benchmark_ToString/uint16-12                                       573383422    2.127  ns/op     0  B/op   0  allocs/op
Benchmark_ToString/uint32-12                                       575723191    2.093  ns/op     0  B/op   0  allocs/op
Benchmark_ToString/uint64-12                                       575901750    2.089  ns/op     0  B/op   0  allocs/op
Benchmark_ToString/string-12                                       613909396    1.959  ns/op     0  B/op   0  allocs/op
Benchmark_ToString/[]uint8-12                                       96832432    12.11  ns/op    16  B/op   1  allocs/op
Benchmark_ToString/bool-12                                         608058547    1.990  ns/op     0  B/op   0  allocs/op
Benchmark_ToString/float32-12                                       23195016    47.11  ns/op     4  B/op   1  allocs/op
Benchmark_ToString/float64-12                                       17204126    70.24  ns/op     4  B/op   1  allocs/op
Benchmark_ToString/time.Time-12                                     13103935    91.85  ns/op    24  B/op   1  allocs/op
Benchmark_ToString/time.Time#01-12                                  13198113    91.22  ns/op    24  B/op   1  allocs/op
Benchmark_ToString/[]string-12                                      65187865    18.35  ns/op    16  B/op   1  allocs/op
Benchmark_ToString/[]int-12                                         54417859    21.53  ns/op     8  B/op   1  allocs/op
Benchmark_ToString/[2]int-12                                        32691942    36.57  ns/op    16  B/op   1  allocs/op
Benchmark_ToString/[][]int-12                                        9382754    128.8  ns/op   112  B/op   6  allocs/op
Benchmark_ToString/[]interface_{}-12                                10584483    114.5  ns/op    72  B/op   3  allocs/op
Benchmark_ToString/utils.MyStringer-12                             365979882    3.277  ns/op     0  B/op   0  allocs/op
Benchmark_ToString/utils.CustomType-12                              11649330    102.5  ns/op    16  B/op   1  allocs/op
Benchmark_ToString_concurrency/int-12                             1000000000   0.2619  ns/op     0  B/op   0  allocs/op
Benchmark_ToString_concurrency/int8-12                            1000000000   0.2202  ns/op     0  B/op   0  allocs/op
Benchmark_ToString_concurrency/int16-12                           1000000000   0.2708  ns/op     0  B/op   0  allocs/op
Benchmark_ToString_concurrency/int32-12                           1000000000   0.2658  ns/op     0  B/op   0  allocs/op
Benchmark_ToString_concurrency/int64-12                           1000000000   0.2658  ns/op     0  B/op   0  allocs/op
Benchmark_ToString_concurrency/uint-12                            1000000000   0.2281  ns/op     0  B/op   0  allocs/op
Benchmark_ToString_concurrency/uint8-12                           1000000000   0.2223  ns/op     0  B/op   0  allocs/op
Benchmark_ToString_concurrency/uint16-12                          1000000000   0.2396  ns/op     0  B/op   0  allocs/op
Benchmark_ToString_concurrency/uint32-12                          1000000000   0.2273  ns/op     0  B/op   0  allocs/op
Benchmark_ToString_concurrency/uint64-12                          1000000000   0.2271  ns/op     0  B/op   0  allocs/op
Benchmark_ToString_concurrency/string-12                          1000000000   0.2117  ns/op     0  B/op   0  allocs/op
Benchmark_ToString_concurrency/[]uint8-12                          213842515    5.718  ns/op    16  B/op   1  allocs/op
Benchmark_ToString_concurrency/bool-12                            1000000000   0.2118  ns/op     0  B/op   0  allocs/op
Benchmark_ToString_concurrency/float32-12                          201081819    6.011  ns/op     4  B/op   1  allocs/op
Benchmark_ToString_concurrency/float64-12                          142000966    8.799  ns/op     4  B/op   1  allocs/op
Benchmark_ToString_concurrency/time.Time-12                         71451783    18.04  ns/op    24  B/op   1  allocs/op
Benchmark_ToString_concurrency/time.Time#01-12                      69313578    17.74  ns/op    24  B/op   1  allocs/op
Benchmark_ToString_concurrency/[]string-12                         187564670    6.455  ns/op    16  B/op   1  allocs/op
Benchmark_ToString_concurrency/[]int-12                            262707805    4.498  ns/op     8  B/op   1  allocs/op
Benchmark_ToString_concurrency/[2]int-12                           129274200    8.777  ns/op    16  B/op   1  allocs/op
Benchmark_ToString_concurrency/[][]int-12                           22638411    52.65  ns/op   112  B/op   6  allocs/op
Benchmark_ToString_concurrency/[]interface_{}-12                    34120837    35.36  ns/op    72  B/op   3  allocs/op
Benchmark_ToString_concurrency/utils.MyStringer-12                1000000000   0.4259  ns/op     0  B/op   0  allocs/op
Benchmark_ToString_concurrency/utils.CustomType-12                  54806094    25.95  ns/op    16  B/op   1  allocs/op
Benchmark_UnsafeBytes/unsafe-12                                   1000000000   0.5658  ns/op     0  B/op   0  allocs/op
Benchmark_UnsafeBytes/default-12                                    88407558    13.50  ns/op    16  B/op   1  allocs/op
Benchmark_UnsafeString/unsafe-12                                  1000000000   0.3545  ns/op     0  B/op   0  allocs/op
Benchmark_UnsafeString/default-12                                  100000000    12.09  ns/op    16  B/op   1  allocs/op
Benchmark_ByteSize/0-12                                            395954607    3.023  ns/op     0  B/op   0  allocs/op
Benchmark_ByteSize/1-12                                             65295756    18.15  ns/op    16  B/op   1  allocs/op
Benchmark_ByteSize/500-12                                           58264801    20.92  ns/op    16  B/op   1  allocs/op
Benchmark_ByteSize/1024-12                                          60886531    19.80  ns/op    16  B/op   1  allocs/op
Benchmark_ByteSize/1126-12                                          53409986    22.69  ns/op    16  B/op   1  allocs/op
Benchmark_ByteSize/1048576-12                                       60969927    19.41  ns/op    16  B/op   1  allocs/op
Benchmark_ByteSize/1153024-12                                       53647869    22.12  ns/op    16  B/op   1  allocs/op
Benchmark_ByteSize/1073741824-12                                    63792180    19.05  ns/op    16  B/op   1  allocs/op
Benchmark_ByteSize/1180696576-12                                    54560540    22.02  ns/op    16  B/op   1  allocs/op
Benchmark_ByteSize/1099511627776-12                                 64080169    18.85  ns/op    16  B/op   1  allocs/op
Benchmark_ByteSize/1209033293824-12                                 52957434    22.01  ns/op    16  B/op   1  allocs/op
Benchmark_ByteSize/1125899906842624-12                              65629659    18.33  ns/op    16  B/op   1  allocs/op
Benchmark_ByteSize/1238050092875776-12                              56535770    21.73  ns/op    16  B/op   1  allocs/op
Benchmark_ByteSize/1152921504606846976-12                           64569356    18.56  ns/op    16  B/op   1  allocs/op
Benchmark_ByteSize/1267763295104794624-12                           56481996    21.10  ns/op    16  B/op   1  allocs/op

# Format and Append
Benchmark_FormatUint/small/fiber-12                                607527520    1.966  ns/op     0  B/op   0  allocs/op
Benchmark_FormatUint/small/strconv-12                              607521366    1.973  ns/op     0  B/op   0  allocs/op
Benchmark_FormatUint/medium/fiber-12                                64427509    19.04  ns/op    16  B/op   1  allocs/op
Benchmark_FormatUint/medium/strconv-12                              59566404    20.42  ns/op    16  B/op   1  allocs/op
Benchmark_FormatUint/large/fiber-12                                 45395149    26.16  ns/op    24  B/op   1  allocs/op
Benchmark_FormatUint/large/strconv-12                               45620366    26.38  ns/op    24  B/op   1  allocs/op
Benchmark_FormatInt/small_pos/fiber-12                             608898928    1.963  ns/op     0  B/op   0  allocs/op
Benchmark_FormatInt/small_pos/strconv-12                           598721480    1.976  ns/op     0  B/op   0  allocs/op
Benchmark_FormatInt/small_neg/fiber-12                             616958124    1.946  ns/op     0  B/op   0  allocs/op
Benchmark_FormatInt/small_neg/strconv-12                            87181050    13.77  ns/op     3  B/op   1  allocs/op
Benchmark_FormatInt/medium_pos/fiber-12                             63105722    19.12  ns/op    16  B/op   1  allocs/op
Benchmark_FormatInt/medium_pos/strconv-12                           57454753    20.70  ns/op    16  B/op   1  allocs/op
Benchmark_FormatInt/medium_neg/fiber-12                             63631222    19.10  ns/op    16  B/op   1  allocs/op
Benchmark_FormatInt/medium_neg/strconv-12                           61296942    20.17  ns/op    16  B/op   1  allocs/op
Benchmark_FormatInt/large_pos/fiber-12                              48604558    25.08  ns/op    24  B/op   1  allocs/op
Benchmark_FormatInt/large_pos/strconv-12                            45605844    26.25  ns/op    24  B/op   1  allocs/op
Benchmark_FormatInt/large_neg/fiber-12                              47388217    25.09  ns/op    24  B/op   1  allocs/op
Benchmark_FormatInt/large_neg/strconv-12                            45871998    26.10  ns/op    24  B/op   1  allocs/op
Benchmark_FormatUint32/fiber-12                                     63452196    18.63  ns/op    16  B/op   1  allocs/op
Benchmark_FormatUint32/strconv-12                                   59485942    20.08  ns/op    16  B/op   1  allocs/op
Benchmark_FormatInt32/fiber-12                                      63030724    18.98  ns/op    16  B/op   1  allocs/op
Benchmark_FormatInt32/strconv-12                                    61887302    19.69  ns/op    16  B/op   1  allocs/op
Benchmark_FormatUint16/fiber-12                                     80149611    14.48  ns/op     5  B/op   1  allocs/op
Benchmark_FormatUint16/strconv-12                                   77022440    15.43  ns/op     5  B/op   1  allocs/op
Benchmark_FormatInt16/fiber-12                                      79013646    15.23  ns/op     8  B/op   1  allocs/op
Benchmark_FormatInt16/strconv-12                                    79695165    15.24  ns/op     8  B/op   1  allocs/op
Benchmark_FormatUint8/fiber-12                                     599811685    1.947  ns/op     0  B/op   0  allocs/op
Benchmark_FormatUint8/strconv-12                                    84144096    14.18  ns/op     3  B/op   1  allocs/op
Benchmark_FormatInt8/fiber-12                                      630717244    1.985  ns/op     0  B/op   0  allocs/op
Benchmark_FormatInt8/strconv-12                                     83826201    14.24  ns/op     4  B/op   1  allocs/op
Benchmark_AppendUint/fiber-12                                      130817422    9.139  ns/op     0  B/op   0  allocs/op
Benchmark_AppendUint/strconv-12                                    100000000    10.08  ns/op     0  B/op   0  allocs/op
Benchmark_AppendInt/small_neg/fiber-12                             369512403    3.266  ns/op     0  B/op   0  allocs/op
Benchmark_AppendInt/small_neg/strconv-12                           213341739    5.627  ns/op     0  B/op   0  allocs/op
Benchmark_AppendInt/medium_neg/fiber-12                            125937435    9.531  ns/op     0  B/op   0  allocs/op
Benchmark_AppendInt/medium_neg/strconv-12                          122490632    9.791  ns/op     0  B/op   0  allocs/op

# Token
Benchmark_GenerateSecureToken/16_bytes-12                            4565527    258.6  ns/op    24  B/op   1  allocs/op
Benchmark_GenerateSecureToken/32_bytes-12                            4306404    280.8  ns/op    48  B/op   1  allocs/op
Benchmark_TokenGenerators/UUIDv4-12                                  4019139    288.2  ns/op    64  B/op   2  allocs/op
Benchmark_TokenGenerators/SecureToken-12                             4360036    276.9  ns/op    48  B/op   1  allocs/op

# HTTP
Benchmark_GetMIME/fiber-12                                          22321272    53.90  ns/op     0  B/op   0  allocs/op
Benchmark_GetMIME/default-12                                        17492530    68.46  ns/op     0  B/op   0  allocs/op
Benchmark_ParseVendorSpecificContentType/vendorContentType-12      125467813    9.619  ns/op     0  B/op   0  allocs/op
Benchmark_ParseVendorSpecificContentType/defaultContentType-12     404169172    2.974  ns/op     0  B/op   0  allocs/op
Benchmark_StatusMessage/fiber-12                                  1000000000   0.3349  ns/op     0  B/op   0  allocs/op
Benchmark_StatusMessage/default-12                                 460456902    2.610  ns/op     0  B/op   0  allocs/op

# IP
Benchmark_IsIPv4/fiber-4                                            56396187    21.72  ns/op     0  B/op   0  allocs/op
Benchmark_IsIPv4/default-4                                          28357074    40.38  ns/op     0  B/op   0  allocs/op
Benchmark_IsIPv6/fiber-4                                            19461662    62.01  ns/op     0  B/op   0  allocs/op
Benchmark_IsIPv6/default-4                                          13315670    89.84  ns/op     0  B/op   0  allocs/op

# Parse
Benchmark_ParseUint/fiber-12                                       236748204    5.049  ns/op     0  B/op   0  allocs/op
Benchmark_ParseUint/fiber_bytes-12                                 224650773    5.348  ns/op     0  B/op   0  allocs/op
Benchmark_ParseUint/default-12                                      88588122    13.75  ns/op     0  B/op   0  allocs/op
Benchmark_ParseUint_DigitRuns/6digit-12                            207540178    5.769  ns/op     0  B/op   0  allocs/op
Benchmark_ParseUint_DigitRuns/8digit-12                            222360716    5.403  ns/op     0  B/op   0  allocs/op
Benchmark_ParseUint_DigitRuns/12digit-12                           156132950    7.699  ns/op     0  B/op   0  allocs/op
Benchmark_ParseUint_DigitRuns/19digit-12                           135049720    8.880  ns/op     0  B/op   0  allocs/op
Benchmark_ParseUint_DigitRuns/1digit-12                            338642533    3.553  ns/op     0  B/op   0  allocs/op
Benchmark_ParseUint_DigitRuns/4digit-12                            212370570    5.672  ns/op     0  B/op   0  allocs/op
Benchmark_ParseInt/fiber-12                                        299791800    3.981  ns/op     0  B/op   0  allocs/op
Benchmark_ParseInt/fiber_bytes-12                                  288714712    4.165  ns/op     0  B/op   0  allocs/op
Benchmark_ParseInt/default-12                                       76370292    15.48  ns/op     0  B/op   0  allocs/op
Benchmark_ParseInt32/fiber-12                                      200451391    5.988  ns/op     0  B/op   0  allocs/op
Benchmark_ParseInt32/fiber_bytes-12                                201629558    5.956  ns/op     0  B/op   0  allocs/op
Benchmark_ParseInt32/default-12                                     78384832    15.71  ns/op     0  B/op   0  allocs/op
Benchmark_ParseInt16/fiber-12                                      220670613    5.462  ns/op     0  B/op   0  allocs/op
Benchmark_ParseInt16/fiber_bytes-12                                220175068    5.430  ns/op     0  B/op   0  allocs/op
Benchmark_ParseInt16/default-12                                    100000000    10.71  ns/op     0  B/op   0  allocs/op
Benchmark_ParseInt8/fiber-12                                       277948545    4.279  ns/op     0  B/op   0  allocs/op
Benchmark_ParseInt8/fiber_bytes-12                                 264784368    4.566  ns/op     0  B/op   0  allocs/op
Benchmark_ParseInt8/default-12                                     142184748    8.373  ns/op     0  B/op   0  allocs/op
Benchmark_ParseUint32/fiber-12                                     238916116    5.025  ns/op     0  B/op   0  allocs/op
Benchmark_ParseUint32/fiber_bytes-12                               222286592    5.409  ns/op     0  B/op   0  allocs/op
Benchmark_ParseUint32/default-12                                    90395479    13.33  ns/op     0  B/op   0  allocs/op
Benchmark_ParseUint16/fiber-12                                     251398184    4.828  ns/op     0  B/op   0  allocs/op
Benchmark_ParseUint16/fiber_bytes-12                               248772012    4.838  ns/op     0  B/op   0  allocs/op
Benchmark_ParseUint16/default-12                                   137015901    8.788  ns/op     0  B/op   0  allocs/op
Benchmark_ParseUint8/fiber-12                                      360430984    3.427  ns/op     0  B/op   0  allocs/op
Benchmark_ParseUint8/fiber_bytes-12                                327526336    3.659  ns/op     0  B/op   0  allocs/op
Benchmark_ParseUint8/default-12                                    181904056    6.438  ns/op     0  B/op   0  allocs/op
Benchmark_ParseFloat64/fiber-12                                     82912768    14.76  ns/op     0  B/op   0  allocs/op
Benchmark_ParseFloat64/fiber_bytes-12                               95692504    12.68  ns/op     0  B/op   0  allocs/op
Benchmark_ParseFloat64/default-12                                   50109265    25.05  ns/op     0  B/op   0  allocs/op
Benchmark_ParseFloat32/fiber-12                                     76648135    15.76  ns/op     0  B/op   0  allocs/op
Benchmark_ParseFloat32/fiber_bytes-12                               86422119    13.63  ns/op     0  B/op   0  allocs/op
Benchmark_ParseFloat32/default-12                                   47198646    25.41  ns/op     0  B/op   0  allocs/op

# Time
Benchmark_CalculateTimestamp/fiber-12                             1000000000   0.3366  ns/op     0  B/op   0  allocs/op
Benchmark_CalculateTimestamp/default-12                             36163686    32.69  ns/op     0  B/op   0  allocs/op
Benchmark_CalculateTimestamp/fiber_asserted-12                       4471299    267.8  ns/op    12  B/op   2  allocs/op
Benchmark_CalculateTimestamp/default_asserted-12                     3991147    298.7  ns/op     8  B/op   2  allocs/op

# URL
Benchmark_AppendPathSegmentsEscape/1-segment/fiber-12               84056664    13.99  ns/op     0  B/op   0  allocs/op
Benchmark_AppendPathSegmentsEscape/1-segment/split-loop-12          56022625    21.97  ns/op     0  B/op   0  allocs/op
Benchmark_AppendPathSegmentsEscape/3-segments/fiber-12              88724314    13.65  ns/op     0  B/op   0  allocs/op
Benchmark_AppendPathSegmentsEscape/3-segments/split-loop-12         36393044    32.41  ns/op     0  B/op   0  allocs/op
Benchmark_AppendPathSegmentsEscape/6-segments/fiber-12              87622688    13.82  ns/op     0  B/op   0  allocs/op
Benchmark_AppendPathSegmentsEscape/6-segments/split-loop-12         23307777    51.23  ns/op     0  B/op   0  allocs/op
Benchmark_AppendPathSegmentsEscape/escaping/fiber-12                37647206    31.85  ns/op     0  B/op   0  allocs/op
Benchmark_AppendPathSegmentsEscape/escaping/split-loop-12           21136993    58.06  ns/op     0  B/op   0  allocs/op

# XML
Benchmark_GolangXMLEncoder-12                                         574852     2040  ns/op  4864  B/op  12  allocs/op
Benchmark_DefaultXMLEncoder-12                                        593738     2012  ns/op  4864  B/op  12  allocs/op
Benchmark_DefaultXMLDecoder-12                                        309031     3876  ns/op  2892  B/op  57  allocs/op

See all the benchmarks under https://gofiber.github.io/utils/benchmarks

Case-insensitive matching helpers

EqualFold, IndexFold, ContainsFold, HasPrefixFold, and HasSuffixFold compare ASCII case-insensitively using the SWAR word loops: only A..Z/a..z fold, every other byte (including bytes

= 0x80) must match exactly. HasPrefixFold and HasSuffixFold cover the header checks Fiber otherwise spells as an allocation-prone ToLower + HasPrefix/HasSuffix pair (authorization schemes such as Bearer, content-type prefixes such as multipart/form-data, suffixes such as +json), and like the other Fold helpers they take the needle as a plain string because call sites pass constant tokens. Their Benchmark_HasPrefixFold/Benchmark_HasSuffixFold numbers are tracked on the benchmark charts and join the catalog above on its next regeneration.

HashFold is the hashing half of a case-insensitive lookup table whose other half is EqualFold: strings EqualFold reports equal hash equal, so a table of field or header names can be probed with a key in any case without first lower-casing a copy of it. It folds each word with swar.ToLowerWord as it loads it and mixes with wyhash's widening multiply: keys under eight bytes, as most are, pack into one word and cost one multiply, with the length in the multiplier so that keys which pack alike, such as a and aa, stay apart; longer keys take one multiply per sixteen bytes plus a final one. It takes no seed and is no defense against collisions planned in advance, so it suits keys of the program's own, such as the fields of a struct, rather than keys an attacker picks. Against maphash.String of a strings.ToLower copy, benchstat over ten runs on an Intel Xeon @ 2.80GHz measured 4.8 ns against 13.2 ns for a 2-byte key, 4.5 ns against 50.7 ns for a 4-byte key and 14.7 ns against 184 ns for a 48-byte key, where the copy also allocates; go test -run='^$' -bench='^Benchmark_HashFold$' -benchmem -count=10 . > hashfold.txt followed by benchstat hashfold.txt reproduces that comparison. The HashFold rows in the amd64 table below, like the table's other rows, are a single run on the machine its header names.

HTTP dates

AppendHTTPDate and FormatHTTPDate write a time in the RFC 9110 preferred HTTP date format (Mon, 02 Jan 2006 15:04:05 GMT, net/http.TimeFormat), byte-identical to time.Format with that layout but without walking a layout string: the calendar fields come from one civil-date conversion of t.Unix() (Hinnant's era arithmetic, instead of the three abs() walks behind Date, Clock, and Weekday), and are written into the fixed-width template with two-digit table lookups. ParseHTTPDate is the reverse: canonical preferred-format input takes a strict scalar fast path whose validated fields feed time.Unix directly — the same Time value time.Date builds, minus its normalization pass — and everything else — the obsolete RFC 850 and asctime forms, unusual casing, non-GMT zone names, padding — falls back to time.Parse with net/http.ParseTime semantics, including its errors. Both directions are pinned to the time package by a day-by-day sweep over the years 0..9999. Date, Last-Modified, and If-Modified-Since handling sit on every request/response, which makes these the highest-leverage helpers in this group for Fiber.

URL escaping

AppendQueryEscape/AppendPathEscape and AppendQueryUnescape/AppendPathUnescape produce byte-identical results (and, for the unescape pair, identical url.EscapeError values) to their net/url counterparts, as append-style, allocation-free single passes. The escape tables are pinned to net/url.shouldEscape by exhaustive per-byte tests. Unescaping jumps between escape sites with the vectorized scans (IndexAny2 when + needs rewriting, bytes.IndexByte otherwise) and copies clean spans wholesale, so route parameters and query values without escapes — the common case — cost one scan and one copy. Decoding never grows the input, so dst may be s[:0] on a common backing array to unescape in place; escaping can grow the input, so there dst must not alias s.

AppendPathSegmentsEscape covers a whole multi-segment path in one pass: it escapes every segment as AppendPathEscape does and keeps the / between them. The output equals escaping each segment and joining with /, pinned per byte and by fuzzing; net/url's whole-path escaping differs, as it also leaves ; and , unescaped. The catalog above measures it against the per-segment loop a caller writes without it; the other URL benchmarks are still in the amd64 block below.

JSON string escaping

AppendJSONString appends a value as a double-quoted JSON string, byte-identical to encoding/json.Marshal of the same string — including its default HTML escaping (<, >, &), the \ufffd replacement of invalid UTF-8 bytes, and the U+2028/U+2029 escapes — without any of Marshal's reflection or allocation. Clean spans are located with a SWAR scan (the same first-match-mask technique as IndexNonQuotable) and copied wholesale. This is the building block for hand-rolled JSON hot paths such as access-log lines and error bodies.

IP address parsing

ParseIPv4 and ParseIPv6 parse addresses into netip.Addr, accepting exactly the strings netip.ParseAddr accepts for the respective family (pinned by fuzzing) while reporting failure with a bool instead of a constructed error. Both take strings or byte slices, so fasthttp-style callers skip the string conversion entirely; remote-address and trusted-proxy checks parse an IP on every request in Fiber.

Header key canonicalization

CanonicalHeaderKey Title-Cases an HTTP header key exactly like net/http.CanonicalHeaderKey, including its return-unchanged guard for keys containing non-token bytes. Already-canonical keys — the common case on receive paths — are validated in a single table pass and returned as-is with zero allocations for strings and byte slices alike. Keys that do need rewriting cost one allocation; note that for the ~40 header names in the stdlib's interning table the stdlib returns a cached string without allocating, so this helper's edge there is time, not allocations.

Control-byte scanning

IndexControl returns the index of the first ASCII control byte — a byte below 0x20 or DEL (0x7F), the RFC 5234 CTL set — and IndexControlExceptTab is the same scan with HTAB permitted, which is the byte set an RFC 9110 field value may not contain. Both are SWAR first-match scans (two words per branch, one overlapping word for the tail) over strings or byte slices; the HTAB exemption is tested only in words that hold a control byte, so clean input costs the same either way. They never match bytes >= 0x80, so unlike strings.IndexFunc(s, unicode.IsControl) they neither decode UTF-8 nor flag the C1 range hidden inside it. Fiber spells this check by hand in half a dozen places — header values before they are echoed, request IDs, Location values, log fields, Basic auth credentials — and each copy is one of these two calls.

Byte-separator cuts

CutByte and LastCutByte are strings.Cut/bytes.Cut for a single byte separator, around its first or last occurrence, generic over strings and byte slices. They return the two parts and a found flag exactly like the stdlib pair (including the ""/nil after-part of a miss), cost one IndexByte/LastIndexByte, and spare []byte callers the []byte{sep} needle and the length dispatch inside bytes.Index. CutByte beats strings.Cut; LastCutByte has no stdlib counterpart, so its row is measured against a hand-written LastIndexByte split, which it trails by the cost of the call — its value is the generic []byte support and the readable spelling. Header parameter splits (;), key=value pairs, and host/port and name/extension splits are the intended call sites.

Host and port splitting

SplitHostPort splits host:port, host%zone:port, [host]:port, and [host%zone]:port with exactly net.SplitHostPort's acceptance rules (pinned by fuzzing against it), but reports failure with a bool instead of constructing a *net.AddrError, and accepts byte slices. Valid input costs the same as the stdlib — the scan is the same three IndexByte calls — so the win is on the rejection path, where a malformed Host or Forwarded value no longer costs an allocation, and on []byte input, which no longer needs a string conversion first.

List field iteration

SplitTrimSeq returns an iterator over the elements of a list separated by one byte, with ASCII whitespace trimmed from each element and empty elements skipped — how HTTP list fields such as Accept-Encoding, Connection, Vary, and Cache-Control are read (RFC 9110 Section 5.6.1: optional whitespace around the commas, empty elements ignored). It replaces the strings.SplitSeq + TrimSpace + emptiness-check triplet, locates each separator with a single IndexByte, works on strings and byte slices alike, and yields subslices without copying. In an ordinary caller the iterator inlines and allocates nothing, like strings.SplitSeq; the benchmark ranges inside a helper function for that reason, because calls made directly inside a b.Loop body are never inlined and would show the closure allocations instead.

Duration formatting

AppendDuration renders a time.Duration exactly as d.String() does — "72h3m0.5s", "1.5ms", "0s" — into the caller's buffer, with the two-digit table for the field digits; a value with no fraction, the common case, never touches the fraction digits. d.String() allocates its result and fmt.Fprintf("%v", d), which Fiber's logger uses for the latency column, costs several times more on top; an append-style form makes per-request duration rendering (access logs, Server-Timing) allocation-free.

Decimal formatting

FormatUint/FormatInt (and their 32- and 16-bit variants) and AppendUint/AppendInt render integers eight digits at a time: a value below 1e8 becomes eight zero-padded digit lanes through a fixed sequence of multiplies, shifts, and masks (the SWAR inverse of the 8-digit parse step in ParseInt), so a 64-bit value costs at most three such conversions and two divisions, all independent of each other, instead of one dependent divide-and-store per digit; the first significant digit is found with a trailing-zero count. Values below 100 come from a precomputed table, and the output is pinned to strconv by a dense sweep plus every decimal and lane-group boundary. GetMIME in the same spirit looks up extensions through a hash table keyed by the extension packed into one lower-cased word with its length in the top lane, so a hit is a multiply, a shift, and one slot comparison, with no allocation even for upper-case input.

These helpers were added on an amd64 machine, so like the simd numbers their benchmarks are recorded separately from the arm64 catalog above and join it on its next regeneration. The block also carries the current numbers for the paths reworked on the same machine (integer formatting, GetMIME, token-sized EqualFold), whose arm64 rows above predate that work:

Environment: goos: linux goarch: amd64 pkg: github.com/gofiber/utils/v2 cpu: AMD EPYC

// go test -benchmem -run=^$ -count=1 . -bench='^Benchmark_(FormatUint|FormatInt|FormatUint32|FormatInt32|FormatUint16|FormatInt16|AppendUint|AppendInt|EqualFold_Short|HashFold|GetMIME|AppendHTTPDate|ParseHTTPDate|AppendDuration|AppendQueryEscape|AppendQueryUnescape|AppendPathUnescape|AppendJSONString|ParseIPv4|ParseIPv6|CanonicalHeaderKey|IndexControl|CutByte|LastCutByte|SplitHostPort|SplitTrimSeq)$'
Benchmark_EqualFold_Short/3B/fiber-4                               545916512    2.196  ns/op     0  B/op   0  allocs/op
Benchmark_EqualFold_Short/3B/default-4                             348854562    3.437  ns/op     0  B/op   0  allocs/op
Benchmark_EqualFold_Short/4B/fiber-4                               520734724    2.306  ns/op     0  B/op   0  allocs/op
Benchmark_EqualFold_Short/4B/default-4                             300082318    3.992  ns/op     0  B/op   0  allocs/op
Benchmark_EqualFold_Short/5B/fiber-4                               515355369    2.330  ns/op     0  B/op   0  allocs/op
Benchmark_EqualFold_Short/5B/default-4                             453217892    2.677  ns/op     0  B/op   0  allocs/op
Benchmark_EqualFold_Short/7B/fiber-4                               518183712    2.313  ns/op     0  B/op   0  allocs/op
Benchmark_EqualFold_Short/7B/default-4                             423973927    2.824  ns/op     0  B/op   0  allocs/op
Benchmark_EqualFold_Short/8B/fiber-4                               559857001    2.149  ns/op     0  B/op   0  allocs/op
Benchmark_EqualFold_Short/8B/default-4                             372448862    3.203  ns/op     0  B/op   0  allocs/op
Benchmark_EqualFold_Short/10B/fiber-4                              365249606    3.284  ns/op     0  B/op   0  allocs/op
Benchmark_EqualFold_Short/10B/default-4                            302105649    4.010  ns/op     0  B/op   0  allocs/op
Benchmark_EqualFold_Short/16B/fiber-4                              294948310    4.260  ns/op     0  B/op   0  allocs/op
Benchmark_EqualFold_Short/16B/default-4                            186458998    6.273  ns/op     0  B/op   0  allocs/op
Benchmark_HashFold/2B/fiber-4                                      658326528    1.824  ns/op     0  B/op   0  allocs/op
Benchmark_HashFold/2B/default-4                                    242747058    4.967  ns/op     0  B/op   0  allocs/op
Benchmark_HashFold/4B/fiber-4                                      741680288    1.622  ns/op     0  B/op   0  allocs/op
Benchmark_HashFold/4B/default-4                                     67574636    17.78  ns/op     8  B/op   1  allocs/op
Benchmark_HashFold/12B/fiber-4                                     508330192    2.359  ns/op     0  B/op   0  allocs/op
Benchmark_HashFold/12B/default-4                                    20314017    59.68  ns/op    16  B/op   1  allocs/op
Benchmark_HashFold/17B/fiber-4                                     293925604    4.081  ns/op     0  B/op   0  allocs/op
Benchmark_HashFold/17B/default-4                                    17488249    68.42  ns/op    24  B/op   1  allocs/op
Benchmark_HashFold/48B/fiber-4                                     195048040    6.158  ns/op     0  B/op   0  allocs/op
Benchmark_HashFold/48B/default-4                                    10982050    109.4  ns/op    48  B/op   1  allocs/op
Benchmark_IndexControl/clean-16B/fiber-4                           541015839    2.203  ns/op     0  B/op   0  allocs/op
Benchmark_IndexControl/clean-16B/fiber-except-tab-4                548823001    2.185  ns/op     0  B/op   0  allocs/op
Benchmark_IndexControl/clean-16B/default-4                         146518426    8.165  ns/op     0  B/op   0  allocs/op
Benchmark_IndexControl/clean-64B/fiber-4                           202882459    5.913  ns/op     0  B/op   0  allocs/op
Benchmark_IndexControl/clean-64B/fiber-except-tab-4                202634295    5.917  ns/op     0  B/op   0  allocs/op
Benchmark_IndexControl/clean-64B/default-4                          32725784    36.41  ns/op     0  B/op   0  allocs/op
Benchmark_IndexControl/ctl-at-end-64B/fiber-4                      161422598    7.431  ns/op     0  B/op   0  allocs/op
Benchmark_IndexControl/ctl-at-end-64B/fiber-except-tab-4           167424020    7.199  ns/op     0  B/op   0  allocs/op
Benchmark_IndexControl/ctl-at-end-64B/default-4                     32916850    36.86  ns/op     0  B/op   0  allocs/op
Benchmark_CutByte/fiber-4                                          425650492    2.819  ns/op     0  B/op   0  allocs/op
Benchmark_CutByte/default-4                                        337287391    3.692  ns/op     0  B/op   0  allocs/op
Benchmark_CutByte/fiber-bytes-4                                    395624023    3.036  ns/op     0  B/op   0  allocs/op
Benchmark_CutByte/default-bytes-4                                  333960130    3.599  ns/op     0  B/op   0  allocs/op
Benchmark_LastCutByte/fiber-4                                      780435663    1.543  ns/op     0  B/op   0  allocs/op
Benchmark_LastCutByte/default-4                                    749733099    1.566  ns/op     0  B/op   0  allocs/op
Benchmark_AppendDuration/micros/fiber-4                            214962259    5.587  ns/op     0  B/op   0  allocs/op
Benchmark_AppendDuration/micros/default-4                           82014056    14.20  ns/op     8  B/op   1  allocs/op
Benchmark_AppendDuration/micros/fmt-4                               22779084    53.52  ns/op    16  B/op   2  allocs/op
Benchmark_AppendDuration/millis-frac/fiber-4                       152250303    7.878  ns/op     0  B/op   0  allocs/op
Benchmark_AppendDuration/millis-frac/default-4                      63274092    17.96  ns/op    16  B/op   1  allocs/op
Benchmark_AppendDuration/millis-frac/fmt-4                          20682213    58.15  ns/op    24  B/op   2  allocs/op
Benchmark_AppendDuration/hours/fiber-4                             162731878    7.376  ns/op     0  B/op   0  allocs/op
Benchmark_AppendDuration/hours/default-4                            63937058    18.51  ns/op     8  B/op   1  allocs/op
Benchmark_AppendDuration/hours/fmt-4                                20125533    57.85  ns/op    16  B/op   2  allocs/op
Benchmark_FormatUint/small/fiber-4                                1000000000    1.195  ns/op     0  B/op   0  allocs/op
Benchmark_FormatUint/small/strconv-4                              1000000000    1.191  ns/op     0  B/op   0  allocs/op
Benchmark_FormatUint/medium/fiber-4                                 77792739    14.66  ns/op    16  B/op   1  allocs/op
Benchmark_FormatUint/medium/strconv-4                               86661225    14.33  ns/op    16  B/op   1  allocs/op
Benchmark_FormatUint/large/fiber-4                                  73494848    16.57  ns/op    24  B/op   1  allocs/op
Benchmark_FormatUint/large/strconv-4                                57344931    20.75  ns/op    24  B/op   1  allocs/op
Benchmark_FormatInt/small_pos/fiber-4                             1000000000    1.193  ns/op     0  B/op   0  allocs/op
Benchmark_FormatInt/small_pos/strconv-4                           1000000000    1.177  ns/op     0  B/op   0  allocs/op
Benchmark_FormatInt/small_neg/fiber-4                              867438553    1.394  ns/op     0  B/op   0  allocs/op
Benchmark_FormatInt/small_neg/strconv-4                            132012771    9.100  ns/op     3  B/op   1  allocs/op
Benchmark_FormatInt/medium_pos/fiber-4                              81908667    15.00  ns/op    16  B/op   1  allocs/op
Benchmark_FormatInt/medium_pos/strconv-4                            82768414    14.35  ns/op    16  B/op   1  allocs/op
Benchmark_FormatInt/medium_neg/fiber-4                              80224928    14.83  ns/op    16  B/op   1  allocs/op
Benchmark_FormatInt/medium_neg/strconv-4                            83586040    14.35  ns/op    16  B/op   1  allocs/op
Benchmark_FormatInt/large_pos/fiber-4                               71807041    17.17  ns/op    24  B/op   1  allocs/op
Benchmark_FormatInt/large_pos/strconv-4                             57482294    20.95  ns/op    24  B/op   1  allocs/op
Benchmark_FormatInt/large_neg/fiber-4                               72537430    16.65  ns/op    24  B/op   1  allocs/op
Benchmark_FormatInt/large_neg/strconv-4                             56898590    21.06  ns/op    24  B/op   1  allocs/op
Benchmark_FormatUint32/fiber-4                                      88893556    13.21  ns/op    16  B/op   1  allocs/op
Benchmark_FormatUint32/strconv-4                                    84803842    14.29  ns/op    16  B/op   1  allocs/op
Benchmark_FormatInt32/fiber-4                                       83287166    13.45  ns/op    16  B/op   1  allocs/op
Benchmark_FormatInt32/strconv-4                                     83238232    14.33  ns/op    16  B/op   1  allocs/op
Benchmark_FormatUint16/fiber-4                                     127277752    9.431  ns/op     5  B/op   1  allocs/op
Benchmark_FormatUint16/strconv-4                                   100000000    10.33  ns/op     5  B/op   1  allocs/op
Benchmark_FormatInt16/fiber-4                                      100000000    10.28  ns/op     8  B/op   1  allocs/op
Benchmark_FormatInt16/strconv-4                                    100000000    11.08  ns/op     8  B/op   1  allocs/op
Benchmark_AppendUint/fiber-4                                       166932072    7.187  ns/op     0  B/op   0  allocs/op
Benchmark_AppendUint/strconv-4                                     176215983    6.826  ns/op     0  B/op   0  allocs/op
Benchmark_AppendInt/small_neg/fiber-4                              535174642    2.235  ns/op     0  B/op   0  allocs/op
Benchmark_AppendInt/small_neg/strconv-4                            390787201    3.045  ns/op     0  B/op   0  allocs/op
Benchmark_AppendInt/medium_neg/fiber-4                             166345695    7.211  ns/op     0  B/op   0  allocs/op
Benchmark_AppendInt/medium_neg/strconv-4                           166855051    7.192  ns/op     0  B/op   0  allocs/op
Benchmark_CanonicalHeaderKey/canonical/fiber-4                     168458787    7.093  ns/op     0  B/op   0  allocs/op
Benchmark_CanonicalHeaderKey/canonical/default-4                    96998062    12.35  ns/op     0  B/op   0  allocs/op
Benchmark_CanonicalHeaderKey/common-lower/fiber-4                   58399408    20.13  ns/op    16  B/op   1  allocs/op
Benchmark_CanonicalHeaderKey/common-lower/default-4                 43953460    27.26  ns/op     0  B/op   0  allocs/op
Benchmark_CanonicalHeaderKey/custom-lower/fiber-4                   44137891    27.38  ns/op    24  B/op   1  allocs/op
Benchmark_CanonicalHeaderKey/custom-lower/default-4                 29846257    40.17  ns/op    24  B/op   1  allocs/op
Benchmark_SplitHostPort/host-port/fiber-4                          197468534    6.143  ns/op     0  B/op   0  allocs/op
Benchmark_SplitHostPort/host-port/default-4                        185653338    6.392  ns/op     0  B/op   0  allocs/op
Benchmark_SplitHostPort/ipv6-port/fiber-4                          172519077    6.956  ns/op     0  B/op   0  allocs/op
Benchmark_SplitHostPort/ipv6-port/default-4                        168545616    7.119  ns/op     0  B/op   0  allocs/op
Benchmark_SplitHostPort/missing-port/fiber-4                       317374330    3.745  ns/op     0  B/op   0  allocs/op
Benchmark_SplitHostPort/missing-port/default-4                      70204908    16.85  ns/op    32  B/op   1  allocs/op
Benchmark_GetMIME/fiber-4                                           89935794    13.62  ns/op     0  B/op   0  allocs/op
Benchmark_GetMIME/default-4                                         24408958    48.78  ns/op     0  B/op   0  allocs/op
Benchmark_AppendHTTPDate/fiber-4                                    82853976    14.47  ns/op     0  B/op   0  allocs/op
Benchmark_AppendHTTPDate/default-4                                  20357546    59.42  ns/op     0  B/op   0  allocs/op
Benchmark_ParseHTTPDate/fiber-4                                    135122982    8.880  ns/op     0  B/op   0  allocs/op
Benchmark_ParseHTTPDate/default-4                                   16657530    72.29  ns/op     0  B/op   0  allocs/op
Benchmark_ParseIPv4/fiber-4                                        143262094    8.373  ns/op     0  B/op   0  allocs/op
Benchmark_ParseIPv4/default-4                                       96330211    12.54  ns/op     0  B/op   0  allocs/op
Benchmark_ParseIPv6/compressed/fiber-4                              64978478    17.98  ns/op     0  B/op   0  allocs/op
Benchmark_ParseIPv6/compressed/default-4                            52846597    22.54  ns/op     0  B/op   0  allocs/op
Benchmark_ParseIPv6/full/fiber-4                                    51265544    23.45  ns/op     0  B/op   0  allocs/op
Benchmark_ParseIPv6/full/default-4                                  41648409    29.53  ns/op     0  B/op   0  allocs/op
Benchmark_AppendJSONString/clean-16B/fiber-4                       139753198    8.582  ns/op     0  B/op   0  allocs/op
Benchmark_AppendJSONString/clean-16B/default-4                      19869510    59.22  ns/op    40  B/op   2  allocs/op
Benchmark_AppendJSONString/clean-64B/fiber-4                        46100394    25.94  ns/op     0  B/op   0  allocs/op
Benchmark_AppendJSONString/clean-64B/default-4                      13132239    90.22  ns/op    96  B/op   2  allocs/op
Benchmark_AppendJSONString/escaped-64B/fiber-4                      17267736    69.47  ns/op     0  B/op   0  allocs/op
Benchmark_AppendJSONString/escaped-64B/default-4                     9328038    128.8  ns/op    96  B/op   2  allocs/op
Benchmark_AppendJSONString/unicode-64B/fiber-4                      11569064    104.1  ns/op     0  B/op   0  allocs/op
Benchmark_AppendJSONString/unicode-64B/default-4                     8514000    138.8  ns/op   112  B/op   2  allocs/op
Benchmark_SplitTrimSeq/accept-encoding/fiber-4                     100000000    10.12  ns/op     0  B/op   0  allocs/op
Benchmark_SplitTrimSeq/accept-encoding/default-4                   100000000    11.03  ns/op     0  B/op   0  allocs/op
Benchmark_SplitTrimSeq/accept/fiber-4                               47568871    25.21  ns/op     0  B/op   0  allocs/op
Benchmark_SplitTrimSeq/accept/default-4                             46427307    25.86  ns/op     0  B/op   0  allocs/op
Benchmark_AppendQueryEscape/clean-64B/fiber-4                       61480458    17.97  ns/op     0  B/op   0  allocs/op
Benchmark_AppendQueryEscape/clean-64B/default-4                     33102990    36.57  ns/op     0  B/op   0  allocs/op
Benchmark_AppendQueryEscape/mixed-64B/fiber-4                       14009313    85.76  ns/op     0  B/op   0  allocs/op
Benchmark_AppendQueryEscape/mixed-64B/default-4                     12414153    94.25  ns/op   192  B/op   2  allocs/op
Benchmark_AppendQueryUnescape/plain-64B/fiber-4                    178989290    6.729  ns/op     0  B/op   0  allocs/op
Benchmark_AppendQueryUnescape/plain-64B/default-4                   24298354    49.65  ns/op     0  B/op   0  allocs/op
Benchmark_AppendQueryUnescape/escaped-64B/fiber-4                   12713310    95.28  ns/op     0  B/op   0  allocs/op
Benchmark_AppendQueryUnescape/escaped-64B/default-4                 12207998    98.43  ns/op    48  B/op   1  allocs/op
Benchmark_AppendPathUnescape/plain-25B/fiber-4                     216255505    5.560  ns/op     0  B/op   0  allocs/op
Benchmark_AppendPathUnescape/plain-25B/default-4                    68955292    17.43  ns/op     0  B/op   0  allocs/op
Benchmark_AppendPathUnescape/escaped-31B/fiber-4                    51446673    23.39  ns/op     0  B/op   0  allocs/op
Benchmark_AppendPathUnescape/escaped-31B/default-4                  25162122    47.84  ns/op    24  B/op   1  allocs/op

Float parsing

ParseFloat64 and ParseFloat32 return the float strconv.ParseFloat returns, bit for bit, for an optional sign, digits with an optional point and an optional exponent, in strings or byte slices. The spellings strconv adds (inf, nan, hexadecimal floats, underscores) are syntax errors, and a value too large for the type is a range error; every error comes with a zero result, where strconv returns ±Inf for a range error. A mantissa up to 2^53 (2^24 for ParseFloat32) with an exponent of at most 22 (10) either way is one multiplication or division by an exact power of ten, which rounds correctly (Clinger's fast path, strconv's own first step). An exponent past which every 64-bit mantissa is zero or infinity is settled at once, and so is a product that is an integer times a power of two (the halfway points between floats, integers past 2^53, decimals padded with zeros), with integer arithmetic. Everything else goes to strconv.ParseFloat: the text itself up to 700 bytes, and past that an exact mantissa and exponent or, for a number with more digits than a uint64 holds, at most 768 digits, a final 1 for any nonzero digit after them and an exponent, a form strconv reads correctly however long the input was. Benchmark_ParseFloat_Shapes times each shape against strconv: 2 to 3 times as fast on the fast path, and 1.3 to 1.7 times slower on the numbers handed over to it, whose digits are read twice.

Size strings

ConvertToBytes turns 42, 42kb, 1.5GiB or 130.51MB into a byte count: decimal units are powers of 1000, units with an i are powers of 1024, and the result saturates at math.MaxInt. The number may have a +, a point and an exponent (+2.01k, 1.5e3K), with any number of digits, and is scaled with 128-bit integer arithmetic, so the result is the exact product rounded down (65.35KB is 65350) and never passes through a float64. A number with more digits than a uint64 holds is scaled from its first digits when they and the same digits plus one agree, and otherwise (0.000000000931322574615478515625Gi is exactly one byte) from all of them. A negative or malformed size is 0, and an unknown unit counts as bytes. A whole number, with or without a unit, is one digit loop and a multiplication. Benchmark_ConvertToBytes_Shapes times each shape.

SWAR primitives

The swar package exports the SWAR (SIMD within a register) building blocks the helpers above are composed from: Load8/Store8, Broadcast, ZeroLanes, MatchByteMask/MatchRangeMask, ToLowerWord/ToUpperWord, FirstLane/LastLane, and the WordLen, Ones, HighBits, and LowSeven constants. They are exported so downstream packages (Fiber itself, middleware) can fuse their own byte scans — for example, finding a delimiter while classifying the bytes before it — without re-deriving the bit tricks. The contracts (unchecked bounds preconditions, ZeroLanes' approximate mask, the little-endian lane order) and runnable examples live in the package documentation.

The package benchmarks its primitives against their stdlib counterparts the same way the helpers above do, measuring the canonical loops composed from them: Load8/Store8 vs encoding/binary's little-endian Uint64/PutUint64, a ZeroLanes first-match scan vs strings.IndexByte, a MatchByteMask+LastLane reverse scan vs bytes.LastIndexByte, a MatchRangeMask digit scan vs strings.IndexAny, and an in-place ToLowerWord loop vs bytes.ToLower. The composed loops are pinned to the stdlib results by a dedicated test, and the numbers are tracked per commit on the benchmark charts. Note that strings.IndexByte is hand-written SIMD assembly and overtakes the portable SWAR scan on large inputs; the SWAR primitives earn their keep on short HTTP-sized inputs and on fused scans the stdlib has no single function for. The package's remaining benchmark, Benchmark_Load8_Fusion, is an advisory codegen guard rather than an API performance promise, so it is deliberately not part of the catalog above.

SIMD-accelerated search (package simd)

The simd package is the vector-width counterpart to swar: byte searching and validation whose scan kernels dispatch to AVX2 assembly (four 32-byte vectors per iteration) on amd64 CPUs for inputs of simd.MinLen (32) bytes or more, and fall back to portable loops built on the swar primitives everywhere else, so it builds and behaves identically on every platform. simd.Accelerated() reports which mode is active. CPU capability detection uses golang.org/x/sys/cpu, which also verifies OS support for saving the vector register state.

The AVX2-backed kernels are the multi-needle scans (Memchr2, Memchr3), the paired-byte scan (MemchrPair), the class scans (MemchrDigit/MemchrDigitAt, MemchrWord/MemchrNotWord), the ASCII scans (IsASCII, FirstNonASCII, CountNonASCII), and the substring search (Memmem), which prefilters on the needle's rarest bytes (SelectRareBytes, ByteRank) before verifying candidates — 2-6 byte needles containing two distinct values are scanned for their two rarest bytes at the exact relative distance, longer or single-valued needles for the single rarest byte. Each kernel classifies four 32-byte vectors per iteration. Where the result is a position or a yes/no, the four masks are combined, so a 128-byte block costs a single VPMOVMSKB and a single branch, and the scans that report a position re-extract the four masks in address order on the (rare) hit path. CountNonASCII is the exception — a count cannot be recovered from a combined mask, so its block loop accumulates per-lane counts in vector byte lanes (a signed compare against zero and a byte subtract per vector) and reduces them once at the end, while the remaining whole vectors are extracted and population-counted; it is the one kernel gated on POPCNT in addition to AVX2. One tier is documented explicitly as unaccelerated: MemchrInTable/MemchrNotInTable are plain scalar loops, since an arbitrary 256-entry membership test has no cheap vector form. There is deliberately no single-needle Memchr: bytes.IndexByte is already vector-accelerated by the Go runtime. Memmem delegates to bytes.Index for haystacks of up to 64 bytes, where the stdlib's brute-force vector kernel is level with the paired prefilter (Benchmark_Memmem_Prefilter forces the prefilter helpers at every size to keep that measurable); from 65 bytes bytes.Index switches to a loop anchored on the needle's first byte, and the paired scan takes over. Needles that take the single rare-byte scan keep a 128-byte routing point, since that scan is less selective. Both prefilters bail to bytes.Index after a bounded number of failed candidate verifications, so even adversarial inputs — a rare byte everywhere plus a long almost-matching needle — stay within a constant of the stdlib's O(n+m) (see Benchmark_Memmem_Adversarial). The package operates on []byte only; the generic top-level helpers IsASCII, IndexAny2, and IndexAny3 dispatch into it automatically for inputs of simd.MinLen+ bytes on amd64, which is where the AVX2 kernels overtake the SWAR word loops (-35% to -88% ns/op at 32-512B in benchstat -count=10 runs; shorter inputs keep the existing SWAR paths).

The kernels are adapted from the coregex project's simd package (MIT License, Copyright (c) 2025 Andrey Kolkov and contributors; see simd/LICENSE), with the legacy-SSE register moves in the kernels replaced by VEX-encoded ones to avoid AVX-SSE transition stalls, the scalar tail loops replaced by overlapping vector rescans at the buffer end (a 63-byte scan previously cost ~3.7x a 64-byte one), the 32-byte main loops replaced by 4x unrolled 128-byte blocks whose bound is tested once at the bottom against a precomputed limit pointer, the \w classifier rewritten from three VPMINUB/VPMAXUB clamp-and-compare range tests into two VPSHUFB nibble-table lookups (with the block test reduced to one compare over the four raw class values), the digit range test reduced from two signed compares and a VPANDN to one biased VPADDB and one compare, FirstNonASCII and CountNonASCII given kernels of their own (they were SWAR-only, and the count kernel's block loop accumulates in vector byte lanes rather than extracting and population-counting every vector's mask), the 128-byte block loops placed at fixed offsets inside a 32-byte code window so their throughput no longer depends on where the linker places each kernel, and the fallbacks reworked around the stdlib and the swar package as described above.

Against the pre-unrolling kernels, benchstat -count=10 on the machine below reports -26.6%/-49.7% ns/op for Memchr2 at 512B/4096B, -17.6%/-34.3% for Memchr3, -13.4%/-24.6% for MemchrPair, -39.2%/-50.5% for MemchrDigit, -53.5%/-63.7% for MemchrNotWord, -42.2%/-65.7% for IsASCII, and -13.7%/-27.1% for Memmem, which rides the paired scan. Those percentages come from benchstat over ten runs of each side; the single-run table below is a catalog, not a base-vs-head comparison, so subtracting its rows from an older copy of it will not reproduce them.

Two bands see no benefit and are worth stating plainly. Inputs below simd.MinLen never reach the kernels at all. Inputs of 32-127 bytes do reach them but skip the 128-byte block loop, so they pay its setup with nothing to amortize it against: across that band benchstat reports the class scans clearly ahead (MemchrNotWord -8.6% at 32B, -18.4% at 64B; IsASCII -5.0%/-4.3%), most rows statistically unchanged, and two small regressions — MemchrDigit +5.6% at 32B and Memchr3 +3.8% at 64B. Read those small-input figures against the run's own noise floor: the default legs call unchanged stdlib code, so their movement bounds what a delta of that size means. They held within 1% in the run quoted here, but a later run on the same machine drifted up to 17% on those same rows, so anything under ~10% at 32-64B should be taken as "no measured change" unless its control legs are quiet.

On the portable side, pinning each unrolled group of words with a reslice before loading at constant offsets inside it removes the per-load bounds check that swar.Load8's own reslice otherwise repeats. Measured with benchstat -count=10 against the same fallbacks, at 32B/512B/4KiB: IsASCII -28%/-60%/-63%, CountNonASCII -24%/-44%/-44%, FirstNonASCII -23%/-37%/-43%, Memchr2 -19%/-23%/-25%, MemchrDigit -7%/-12%/-17%, Memchr3 -8%/-13%/-18%, MemchrWord -11%/-8%/-11%, MemchrNotWord -5%/-7%/-6%. The tier a group adds costs one compare on inputs too short to use it, which shows up as +3% to +10% on some of the 8B fallback rows — a few tenths of a nanosecond, and only below the length where the group pays for itself. utils.IsASCII carries the same rework, so the two copies of that scan stay in step.

Making the counting kernel finish its own sub-vector remainder (rather than splitting the input in Go and calling the SWAR loop for the tail) also removed a second non-inlinable call from every whole-vector input: CountNonASCII at 32B went from 11.3ns — behind its own fallback — to 6.8ns, level with it, and it leads from 64B up.

A later audit pass reworked the kernels and fallbacks once more; benchstat -count=10 on the machine below, base vs. head, reports:

  • MemchrDigit -20% at 512B and -27% at 4KiB from the one-add, one-compare range test.
  • MemchrWord -13%/-11% and MemchrNotWord -4%/-10% at 512B/4KiB from comparing the reduced block once instead of every vector, and their SWAR fallbacks -36%/-41% at 32B, -40%/-43% at 64B and -43%/-45% at 512B: 15 ALU operations per word instead of 26, from case-folding the two letter ranges into one test, a one-add underscore test, and a single shared ASCII gate.
  • CountNonASCII -15% at 512B and -41% at 4KiB, with 32B and 64B unchanged: the block loop counts in vector byte lanes (a signed compare against zero and a byte subtract per vector, flushed through VPSADBW every 127 blocks) instead of four port-0 VPMOVMSKB extractions per block. The remaining whole vectors are still extracted and population-counted, because the vector reduction is a fixed ten-cycle chain that one to three vectors cannot amortize — a first version that used the accumulators for those too was 20% slower at 32-64B.
  • MemchrPair's SWAR fallback -33% at 32B, -41% at 64B, -51% at 512B and -52% at 4KiB, and MemchrPair itself -30% at 32B, where the dispatch routes to that fallback: it now scans two words per branch through pinned three-index windows (no per-load capacity check or pointer clamp) and finishes with one overlapping word instead of a scalar tail. Before, at 32B, it ran no faster than a plain scalar loop.
  • Memmem -62% at 96B: needles that take the paired prefilter are routed through it from 65-byte haystacks, where bytes.Index leaves its brute-force vector kernel for a first-byte-anchored loop; 64B and 128B+ are unchanged.

The same pinned-window rework applied to the case-conversion loops in internal/caseconv, which the strings and bytes packages' ToLower and ToUpper build on, gives on the same machine -27% to -37% ns/op for the in-place UnsafeToLower/UnsafeToUpper at 39-64B, -14% to -19% for the scan-only path that finds nothing to convert, and -5% to -17% for the allocating conversions, where the allocation dominates. The arm64 catalog rows above were not regenerated for that change.

Comparing the base and head test binaries also showed the untouched MemchrPair kernel ~10% slower at 4KiB, purely because the linker had moved its entry by 32 bytes: on Skylake-derived cores the JCC erratum mitigation keeps a macro-fused compare-and-branch that crosses or ends on a 32-byte boundary out of the decoded-uop cache, so the block loop ran from the legacy decoder. Every block loop is now placed by a BLOCKALIGN macro at a window offset where all of its fused pairs fit (a few once-per-call NOPs, visible as +5% on Memchr2 at 512B and nothing at 4KiB), and an amd64 test reads each kernel's code and fails if a later edit lets a pair straddle a boundary again.

Because the AVX2 kernels only engage on amd64, their benchmark numbers are recorded separately from the arm64 catalog above:

Environment: goos: linux goarch: amd64 pkg: github.com/gofiber/utils/v2/simd cpu: AMD EPYC

// go test ./simd/ -benchmem -run=^$ -bench=Benchmark_ -count=1
Benchmark_Memchr2/8B/simd-4                                        448702150    2.629  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr2/8B/scalar-4                                      458948080    2.591  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr2/8B/default-4                                      80828568    15.19  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr2/32B/simd-4                                       551499657    2.195  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr2/32B/scalar-4                                     257724674    4.609  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr2/32B/default-4                                     74891224    16.10  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr2/64B/simd-4                                       466191375    2.396  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr2/64B/scalar-4                                     153556369    7.813  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr2/64B/default-4                                     43677663    27.44  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr2/512B/simd-4                                      281867703    4.197  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr2/512B/scalar-4                                     22728276    52.57  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr2/512B/default-4                                     5627893    213.3  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr2/4096B/simd-4                                      46009965    26.18  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr2/4096B/scalar-4                                     2840878    423.0  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr2/4096B/default-4                                     729380     1645  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr3/8B/simd-4                                        359856063    3.305  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr3/8B/scalar-4                                      428945610    2.800  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr3/8B/default-4                                      80533312    14.97  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr3/32B/simd-4                                       525750321    2.246  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr3/32B/scalar-4                                     208787151    5.747  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr3/32B/default-4                                     72554917    16.61  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr3/64B/simd-4                                       456248272    2.608  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr3/64B/scalar-4                                     122297224    9.814  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr3/64B/default-4                                     42806076    28.02  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr3/512B/simd-4                                      225914192    5.260  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr3/512B/scalar-4                                     17531822    68.20  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr3/512B/default-4                                     5573582    215.2  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr3/4096B/simd-4                                      32023327    37.51  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr3/4096B/scalar-4                                     2226567    539.9  ns/op     0  B/op   0  allocs/op
Benchmark_Memchr3/4096B/default-4                                     732044     1639  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrPair/8B/simd-4                                     217282616    5.509  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrPair/8B/swar-4                                     314719844    3.574  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrPair/8B/scalar-4                                   422881550    2.779  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrPair/32B/simd-4                                    207050652    5.801  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrPair/32B/swar-4                                    248582592    4.838  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrPair/32B/scalar-4                                   95052945    12.72  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrPair/64B/simd-4                                    377263140    3.186  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrPair/64B/swar-4                                    155256835    7.725  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrPair/64B/scalar-4                                   47530032    25.24  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrPair/512B/simd-4                                   207748032    5.771  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrPair/512B/swar-4                                    24392611    49.23  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrPair/512B/scalar-4                                   5721051    210.3  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrPair/4096B/simd-4                                   36516523    32.85  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrPair/4096B/swar-4                                    3116662    385.4  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrPair/4096B/scalar-4                                   734092     1633  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrDigit/8B/simd-4                                    466294860    2.585  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrDigit/8B/scalar-4                                  667278902    1.592  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrDigit/32B/simd-4                                   603776600    2.026  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrDigit/32B/scalar-4                                 400040438    3.006  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrDigit/64B/simd-4                                   502343226    2.385  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrDigit/64B/scalar-4                                 226996323    5.279  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrDigit/512B/simd-4                                  316641714    3.788  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrDigit/512B/scalar-4                                 32100192    37.41  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrDigit/4096B/simd-4                                  57886653    20.71  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrDigit/4096B/scalar-4                                 3979412    301.9  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrWord/8B/simd-4                                     420807253    2.854  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrWord/8B/scalar-4                                   539682006    2.224  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrWord/32B/simd-4                                    468429864    2.584  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrWord/32B/scalar-4                                  186980841    6.076  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrWord/64B/simd-4                                    431646770    2.784  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrWord/64B/scalar-4                                  100000000    10.85  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrWord/512B/simd-4                                   200920446    7.052  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrWord/512B/scalar-4                                  15099314    79.49  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrWord/4096B/simd-4                                   28554024    42.03  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrWord/4096B/scalar-4                                  1884114    636.3  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrNotWord/8B/simd-4                                  406962678    2.951  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrNotWord/8B/scalar-4                                508065927    2.354  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrNotWord/32B/simd-4                                 499139647    2.392  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrNotWord/32B/scalar-4                               192618093    6.216  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrNotWord/64B/simd-4                                 456426800    2.616  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrNotWord/64B/scalar-4                               100000000    11.41  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrNotWord/512B/simd-4                                211134301    5.688  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrNotWord/512B/scalar-4                               14514092    82.87  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrNotWord/4096B/simd-4                                28571172    42.00  ns/op     0  B/op   0  allocs/op
Benchmark_MemchrNotWord/4096B/scalar-4                               1818038    659.7  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem/8B/simd-4                                         254839668    4.806  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem/8B/default-4                                      306084612    3.776  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem/32B/simd-4                                        231904362    5.184  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem/32B/default-4                                     273986822    4.382  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem/64B/simd-4                                        177333220    6.771  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem/64B/default-4                                     200886346    5.969  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem/96B/simd-4                                        139523696    8.212  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem/96B/default-4                                      56131904    21.32  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem/128B/simd-4                                       135103468    8.987  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem/128B/default-4                                     44920484    26.67  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem/192B/simd-4                                       135163220    8.888  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem/192B/default-4                                     28838277    41.55  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem/512B/simd-4                                       100000000    10.07  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem/512B/default-4                                      9984771    120.1  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem/4096B/simd-4                                       31788024    37.74  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem/4096B/default-4                                     1297507    924.7  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/8B/paired-4                             206058856    5.832  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/8B/paired-stdlib-4                      317587828    3.784  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/32B/paired-4                            142196713    8.445  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/32B/paired-stdlib-4                     273816424    4.383  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/32B/single-4                            159189033    7.315  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/32B/single-stdlib-4                     250722778    4.571  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/64B/paired-4                            228785918    5.221  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/64B/paired-stdlib-4                     200992668    5.971  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/64B/single-4                             88249381    13.59  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/64B/single-stdlib-4                     100000000    10.70  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/96B/paired-4                            221194490    5.430  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/96B/paired-stdlib-4                      56390828    21.29  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/96B/single-4                             68078998    17.62  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/96B/single-stdlib-4                      75046800    15.97  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/128B/paired-4                           214110559    5.608  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/128B/paired-stdlib-4                     45139016    26.61  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/128B/single-4                            48956462    24.52  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/128B/single-stdlib-4                     54843796    21.79  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/192B/paired-4                           206683298    5.807  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/192B/paired-stdlib-4                     28947043    41.53  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/192B/single-4                            31107553    38.56  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/192B/single-stdlib-4                     33008841    36.37  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/512B/paired-4                           151729483    7.867  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/512B/paired-stdlib-4                      9849835    119.9  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/512B/single-4                            10850151    110.7  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/512B/single-stdlib-4                     10316330    116.4  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/4096B/paired-4                           33893401    35.44  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/4096B/paired-stdlib-4                     1298043    924.4  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/4096B/single-4                            1297876    925.5  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Prefilter/4096B/single-stdlib-4                     1304458    918.2  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Adversarial/simd-4                                     1146  1045883  ns/op     0  B/op   0  allocs/op
Benchmark_Memmem_Adversarial/default-4                                  1148  1045643  ns/op     0  B/op   0  allocs/op
Benchmark_IsASCII/8B/simd-4                                        552113409    2.182  ns/op     0  B/op   0  allocs/op
Benchmark_IsASCII/8B/swar-4                                       1000000000    1.160  ns/op     0  B/op   0  allocs/op
Benchmark_IsASCII/32B/simd-4                                       552101168    2.180  ns/op     0  B/op   0  allocs/op
Benchmark_IsASCII/32B/swar-4                                       636482116    1.877  ns/op     0  B/op   0  allocs/op
Benchmark_IsASCII/64B/simd-4                                       552066571    2.190  ns/op     0  B/op   0  allocs/op
Benchmark_IsASCII/64B/swar-4                                       575329918    2.075  ns/op     0  B/op   0  allocs/op
Benchmark_IsASCII/512B/simd-4                                      402934330    2.984  ns/op     0  B/op   0  allocs/op
Benchmark_IsASCII/512B/swar-4                                      168495673    7.059  ns/op     0  B/op   0  allocs/op
Benchmark_IsASCII/4096B/simd-4                                      83804049    14.31  ns/op     0  B/op   0  allocs/op
Benchmark_IsASCII/4096B/swar-4                                      24237244    49.80  ns/op     0  B/op   0  allocs/op
Benchmark_FirstNonASCII/8B/simd-4                                  467574552    2.582  ns/op     0  B/op   0  allocs/op
Benchmark_FirstNonASCII/8B/swar-4                                  672393433    1.528  ns/op     0  B/op   0  allocs/op
Benchmark_FirstNonASCII/32B/simd-4                                 602724621    1.992  ns/op     0  B/op   0  allocs/op
Benchmark_FirstNonASCII/32B/swar-4                                 550563612    2.049  ns/op     0  B/op   0  allocs/op
Benchmark_FirstNonASCII/64B/simd-4                                 601575296    2.189  ns/op     0  B/op   0  allocs/op
Benchmark_FirstNonASCII/64B/swar-4                                 495414222    2.695  ns/op     0  B/op   0  allocs/op
Benchmark_FirstNonASCII/512B/simd-4                                416022542    3.035  ns/op     0  B/op   0  allocs/op
Benchmark_FirstNonASCII/512B/swar-4                                 86736036    13.81  ns/op     0  B/op   0  allocs/op
Benchmark_FirstNonASCII/4096B/simd-4                                83493616    14.34  ns/op     0  B/op   0  allocs/op
Benchmark_FirstNonASCII/4096B/swar-4                                10722051    111.5  ns/op     0  B/op   0  allocs/op
Benchmark_CountNonASCII/8B/simd-4                                  439797753    2.791  ns/op     0  B/op   0  allocs/op
Benchmark_CountNonASCII/8B/swar-4                                  703020348    1.906  ns/op     0  B/op   0  allocs/op
Benchmark_CountNonASCII/32B/simd-4                                 553221441    2.191  ns/op     0  B/op   0  allocs/op
Benchmark_CountNonASCII/32B/swar-4                                 513505750    2.155  ns/op     0  B/op   0  allocs/op
Benchmark_CountNonASCII/64B/simd-4                                 551378994    2.185  ns/op     0  B/op   0  allocs/op
Benchmark_CountNonASCII/64B/swar-4                                 379643779    3.180  ns/op     0  B/op   0  allocs/op
Benchmark_CountNonASCII/512B/simd-4                                352317170    3.404  ns/op     0  B/op   0  allocs/op
Benchmark_CountNonASCII/512B/swar-4                                 64683924    18.57  ns/op     0  B/op   0  allocs/op
Benchmark_CountNonASCII/4096B/simd-4                                68396660    17.57  ns/op     0  B/op   0  allocs/op
Benchmark_CountNonASCII/4096B/swar-4                                 8100442    146.6  ns/op     0  B/op   0  allocs/op

☕ Supporters

Fiber is an open-source project that runs on donations to pay the bills, e.g., our domain name, hosting, and serverless infrastructure. If you want to support Fiber, please become a GitHub Sponsor.

CodeRabbit

Blacksmith

Tool Sponsors - supporting Fiber with free IDE licenses and AI credits

JetBrains   OpenAI   Anthropic

📅 Monthly Sponsors
🔥 Fiber Guardian
☕ Fiber Supporter
🪴 Fiber Friend
🎁 One-time Sponsors
🚀 Fiber Hero
🪴 Fiber Friend

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func AddTrailingSlashBytes

func AddTrailingSlashBytes(b []byte) []byte

AddTrailingSlashBytes appends a trailing '/' to b if it does not already end with one. If the input already ends with '/', the original slice is returned. A new slice is returned when a '/' is appended. The original slice is never modified.

func AddTrailingSlashString

func AddTrailingSlashString(s string) string

AddTrailingSlashString appends a trailing '/' to s if it does not already end with one. If the input already ends with '/', the original string is returned. A new string is returned only when a '/' needs to be appended.

func AppendDuration added in v2.5.0

func AppendDuration(dst []byte, d time.Duration) []byte

AppendDuration appends d formatted exactly like time.Duration.String to dst and returns the extended slice, without the string allocation.

func AppendHTTPDate added in v2.4.0

func AppendHTTPDate(dst []byte, t time.Time) []byte

AppendHTTPDate appends t in the RFC 9110 preferred HTTP date format ("Mon, 02 Jan 2006 15:04:05 GMT", net/http.TimeFormat) to dst and returns the extended slice. The output is byte-identical to t.UTC().AppendFormat(dst, http.TimeFormat) and always 29 bytes for the years 0..9999 that HTTP dates can represent; times outside that range delegate to time.AppendFormat.

func AppendInt

func AppendInt(dst []byte, n int64) []byte

AppendInt appends the decimal string representation of n to dst.

func AppendJSONString added in v2.4.0

func AppendJSONString[S byteSeq](dst []byte, s S) []byte

AppendJSONString appends s to dst as a double-quoted JSON string and returns the extended slice. The output is byte-identical to encoding/json.Marshal of the same string value, including its default HTML escaping: '"' and '\\' get backslash escapes; control bytes below 0x20 become \b, \f, \n, \r, \t, or \u00XX; '<', '>', '&' become \u00XX; each invalid UTF-8 byte becomes the six literal characters \ufffd; and the line separators U+2028/U+2029 become the \u2028 and \u2029 escapes. Go 1.27's json/v2 writes that replacement raw, so for invalid UTF-8 the two encodings differ from 1.27 on; both still decode to the same string. All other bytes, including multi-byte UTF-8 sequences, are copied verbatim. dst must not alias s: the output is longer than the input (at minimum by the surrounding quotes), so in-place encoding is impossible and an aliased dst would overwrite bytes before they are read. Clean spans are located with a SWAR scan and copied wholesale, so typical log or header values cost one scan and one copy — with none of encoding/json.Marshal's reflection or allocation.

func AppendPathEscape added in v2.4.0

func AppendPathEscape[S byteSeq](dst []byte, s S) []byte

AppendPathEscape appends the percent-encoded path-segment form of s to dst and returns the extended slice. The output is byte-identical to net/url.PathEscape; the aliasing rule matches AppendQueryEscape.

func AppendPathSegmentsEscape added in v2.6.0

func AppendPathSegmentsEscape[S byteSeq](dst []byte, s S) []byte

AppendPathSegmentsEscape appends the percent-encoded form of the multi-segment path s to dst and returns the extended slice. It escapes every segment as AppendPathEscape does but leaves the '/' between them, so the output matches escaping each segment separately and joining the results with '/'. Use it for a value whose slashes are separators; use AppendPathEscape for one segment, where a slash is data and has to be encoded. Empty and dot segments pass through unchanged, so clean or reject an untrusted value before appending it under a fixed prefix. The aliasing rule matches AppendQueryEscape.

func AppendPathUnescape added in v2.4.0

func AppendPathUnescape[S byteSeq](dst []byte, s S) ([]byte, error)

AppendPathUnescape appends the decoded form of the path component s to dst and returns the extended slice, decoding %XX and leaving '+' verbatim, exactly like net/url.PathUnescape. Error and aliasing behavior match AppendQueryUnescape.

func AppendQueryEscape added in v2.4.0

func AppendQueryEscape[S byteSeq](dst []byte, s S) []byte

AppendQueryEscape appends the percent-encoded form of s to dst and returns the extended slice. The output is byte-identical to net/url.QueryEscape: unreserved bytes pass through, space becomes '+', everything else becomes %XX with uppercase hex. dst must not alias s: escaping can grow the input, so in-place operation is impossible.

func AppendQueryUnescape added in v2.4.0

func AppendQueryUnescape[S byteSeq](dst []byte, s S) ([]byte, error)

AppendQueryUnescape appends the decoded form of the query component s to dst and returns the extended slice, converting '+' to space and %XX to the byte it encodes, exactly like net/url.QueryUnescape including its url.EscapeError values for malformed escapes. On error the returned slice is dst with its original length (its backing array may still have been reallocated by growth). Decoding never grows the input, so dst may be s[:0] on a common backing array to decode in place; any other overlap is invalid. Note that an in-place decode that fails has already overwritten the prefix of s before the malformed escape with decoded bytes — treat s as consumed once an in-place decode starts, error or not.

func AppendUint

func AppendUint(dst []byte, n uint64) []byte

AppendUint appends the decimal string representation of n to dst.

func ByteSize

func ByteSize(bytes uint64) string

ByteSize returns a human-readable byte string of the form 10M, 12.5K, and so forth. The unit that results in the smallest number greater than or equal to 1 is always chosen. Maximum supported input is math.MaxUint64 / 10 (≈ 1844674407370955161).

func CanonicalHeaderKey added in v2.4.0

func CanonicalHeaderKey[S byteSeq](key S) S

CanonicalHeaderKey returns the canonical form of the HTTP header key: the first letter and any letter following a hyphen upper-cased, the rest lower-cased. The output matches net/http.CanonicalHeaderKey byte for byte, including its guard: a key containing any byte outside the header token alphabet is returned unchanged. Unlike the stdlib it accepts byte slices as well as strings and allocates only when the key actually needs rewriting — already-canonical keys, the overwhelmingly common case on receive paths, are validated in one table pass and returned as-is without the stdlib's canonical-key cache lookup.

func ContainsFold added in v2.1.2

func ContainsFold[S byteSeq](s S, needle string) bool

ContainsFold reports whether s contains needle, ASCII case-insensitively.

func ConvertToBytes

func ConvertToBytes(humanReadableString string) int

ConvertToBytes returns integer size of bytes from human-readable string, ex. 42kb, 42M Decimal units are powers of 1000 (42k = 42000); binary units with an 'i' infix are powers of 1024 (42Ki = 43008). Note that ByteSize formats with powers of 1024, so use binary suffixes for a lossless round-trip. The number may have a '+', a point and an exponent (1.5e3K), with any number of digits. The result is the exact product rounded down, capped at math.MaxInt. It is 0 if there is no number or it is negative or malformed; an unknown unit counts as bytes.

func CopyBytes

func CopyBytes(b []byte) []byte

#nosec G103 CopyBytes copies a slice to make it immutable

func CopyString

func CopyString(s string) string

CopyString copies a string to make it immutable

func CutByte added in v2.5.0

func CutByte[S byteSeq](s S, sep byte) (before, after S, found bool)

CutByte is strings.Cut/bytes.Cut for a single-byte separator, generic over strings and byte slices; a miss returns s, the zero S ("" or nil), and false. The parts alias s.

func EqualFold

func EqualFold[S byteSeq](b, s S) bool

EqualFold tests ascii strings or bytes for equality case-insensitively

func FormatHTTPDate added in v2.4.0

func FormatHTTPDate(t time.Time) string

FormatHTTPDate returns t in the RFC 9110 preferred HTTP date format, equal to t.UTC().Format(http.TimeFormat) with a single allocation for the result.

func FormatInt

func FormatInt(n int64) string

FormatInt formats an int64 as a decimal string. It is faster than strconv.FormatInt for most inputs.

func FormatInt8

func FormatInt8(n int8) string

FormatInt8 formats an int8 as a decimal string.

func FormatInt16

func FormatInt16(n int16) string

FormatInt16 formats an int16 as a decimal string.

func FormatInt32

func FormatInt32(n int32) string

FormatInt32 formats an int32 as a decimal string.

func FormatUint

func FormatUint(n uint64) string

FormatUint formats a uint64 as a decimal string. It is faster than strconv.FormatUint for most inputs.

func FormatUint8

func FormatUint8(n uint8) string

FormatUint8 formats a uint8 as a decimal string.

func FormatUint16

func FormatUint16(n uint16) string

FormatUint16 formats a uint16 as a decimal string.

func FormatUint32

func FormatUint32(n uint32) string

FormatUint32 formats a uint32 as a decimal string.

func FunctionName

func FunctionName(fn any) string

FunctionName returns function name

func GenerateSecureToken

func GenerateSecureToken(length int) string

GenerateSecureToken generates a cryptographically secure random token encoded in base64. It uses crypto/rand for randomness and base64.RawURLEncoding for URL-safe output. If length is less than or equal to 0, it defaults to 32 bytes (256 bits of entropy). Panics if the random source fails.

func GetArgument

func GetArgument(arg string) bool

GetArgument check if key is in arguments

func GetMIME

func GetMIME(extension string) string

GetMIME returns the media type of a file extension without parameters, matched case-insensitively with or without the leading dot. Unknown extensions map to MIMEOctetStream; an empty extension yields an empty string.

func HasPrefixFold added in v2.2.0

func HasPrefixFold[S byteSeq](s S, prefix string) bool

HasPrefixFold reports whether s begins with prefix, ASCII case-insensitively: only 'A'..'Z'/'a'..'z' fold, every other byte (including >= 0x80) must match exactly, mirroring IndexFold. An empty prefix matches any s. Like the other Fold helpers the needle is a plain string, since call sites pass constant tokens.

func HasSuffixFold added in v2.2.0

func HasSuffixFold[S byteSeq](s S, suffix string) bool

HasSuffixFold reports whether s ends with suffix, ASCII case-insensitively, under the same folding contract as HasPrefixFold. An empty suffix matches any s.

func HashFold added in v2.6.1

func HashFold[S byteSeq](s S) uint64

HashFold returns a 64-bit hash of s in which ASCII letters are folded to one case: strings that EqualFold reports equal hash equal. It is the hashing half of a case-insensitive lookup table whose other half is EqualFold, for keys such as header or field names, and reads s a word at a time without writing a folded copy of it anywhere. As in EqualFold, only 'A'..'Z' and 'a'..'z' fold; every other byte, including those >= 0x80, hashes as is.

It is not a cryptographic hash, and it takes no seed, so it offers no protection against collisions planned in advance: use it to index keys of the program's own, such as the fields of a struct, and not to store keys an attacker picks. Its values may change between releases; do not persist them.

func IncrementIPRange

func IncrementIPRange(ip net.IP)

IncrementIPRange Find available next IP address

func IndexAny2 added in v2.1.2

func IndexAny2[S byteSeq](s S, a, b byte) int

IndexAny2 returns the index of the first occurrence in s of either a or b, or -1 if neither is present. On amd64 CPUs with AVX2, inputs of 32+ bytes dispatch to package simd instead.

func IndexAny3 added in v2.1.2

func IndexAny3[S byteSeq](s S, a, b, c byte) int

IndexAny3 returns the index of the first occurrence in s of a, b, or c, or -1 if none is present. On amd64 CPUs with AVX2, inputs of 32+ bytes dispatch to package simd instead.

func IndexControl added in v2.5.0

func IndexControl[S byteSeq](s S) int

IndexControl returns the index of the first ASCII control byte in s (below 0x20 or DEL, the RFC 5234 CTL set), or -1. HTAB counts as a control byte; bytes >= 0x80 never match, unlike unicode.IsControl's C1 range.

func IndexControlExceptTab added in v2.5.0

func IndexControlExceptTab[S byteSeq](s S) int

IndexControlExceptTab is IndexControl with HTAB permitted: the bytes an RFC 9110 field value may not contain.

func IndexFold added in v2.1.2

func IndexFold[S byteSeq](s S, needle string) int

IndexFold returns the index of the first ASCII case-insensitive occurrence of needle in s, or -1 if absent. An empty needle matches at index 0. Only 'A'..'Z'/'a'..'z' fold; every other byte (including >= 0x80) must match exactly, so e.g. "no\rcache" does NOT match the needle "no-cache". The needle is a plain string by design: call sites pass constant tokens, and a []byte needle would cost its callers a conversion either way.

func IndexNonQuotable added in v2.1.2

func IndexNonQuotable[S byteSeq](s S) int

IndexNonQuotable returns the index of the first byte of s that cannot appear verbatim inside an RFC 9110 quoted-string — that is, a byte matching c == '\\' || c == '"' || (c < 0x20 && c != '\t') || c == 0x7f — or -1 if every byte is quotable. qdtext is HTAB / SP / %x21 / %x23-5B / %x5D-7E / obs-text, so HTAB and bytes >= 0x80 are quotable. Returning the index (rather than a bool) lets callers copy the clean prefix and start escaping exactly at the offending byte. Inputs of 8+ bytes finish with one overlapping word at n-8, shorter ones byte-wise.

func IsASCII added in v2.1.2

func IsASCII[S byteSeq](s S) bool

IsASCII reports whether s contains only ASCII bytes (no byte >= 0x80). It ORs four words per iteration where possible (no index is needed, so detection can be deferred to one test per 32 bytes), then two, then word-wise; inputs of 8+ bytes finish with one overlapping word at n-8, shorter ones byte-wise. On amd64 CPUs with AVX2, inputs of 32+ bytes dispatch to package simd instead.

The unrolled loops pin their group of words with a reslice and load at constant offsets inside it. swar.Load8's own reslice is bounds-checked against the backing array, which the length-based loop condition does not imply, so a variable index costs a compare and a branch per load; pinning the window pays that once per group instead. This mirrors simd.isASCIIGeneric — the same scan, kept in step so a retune of either is a retune of both.

func IsIPv4

func IsIPv4(s string) bool

IsIPv4 reports whether s is a dotted-decimal IPv4 address. It accepts exactly what net.ParseIP accepts for the IPv4 case, without the net.IP slice, so it makes no allocations. It is the validate-only spelling of ParseIPv4, which accepts the same strings and also returns the address.

func IsIPv6

func IsIPv6(s string) bool

IsIPv6 reports whether s is an IPv6 address. It accepts exactly what net.ParseIP accepts for the IPv6 case, without the net.IP slice, so it makes no allocations. That excludes a "%zone" suffix, because net.ParseIP rejects zones.

ParseIPv6 follows netip.ParseAddr instead and does accept zones, so the two disagree on zoned input by design. Callers relying on IsIPv6 to reject zones must screen '%' themselves before substituting ParseIPv6.

func LastCutByte added in v2.5.0

func LastCutByte[S byteSeq](s S, sep byte) (before, after S, found bool)

LastCutByte is CutByte around the last occurrence of sep.

func ParseFloat32

func ParseFloat32[S byteSeq](s S) (float32, error)

ParseFloat32 is ParseFloat64 for float32, rounded once from the decimal.

func ParseFloat64

func ParseFloat64[S byteSeq](s S) (float64, error)

ParseFloat64 parses a decimal ASCII string or byte slice into the float64 that strconv.ParseFloat returns, bit for bit. Only a sign, digits, a point and an exponent are accepted; inf, nan, hex floats and underscores are syntax errors. It returns (0, error) on error and on overflow, where strconv returns ±Inf.

func ParseHTTPDate added in v2.4.0

func ParseHTTPDate[S byteSeq](s S) (time.Time, error)

ParseHTTPDate parses an HTTP date the way net/http.ParseTime does: the RFC 9110 preferred format ("Mon, 02 Jan 2006 15:04:05 GMT") plus the obsolete RFC 850 and ANSI C asctime forms, with surrounding ASCII whitespace tolerated. Canonical preferred-format input takes a fast scalar path that never calls time.Parse; every other input — legacy formats, unusual casing, non-GMT zone names, padding — falls back to time.Parse with byte-for-byte stdlib semantics, including its errors. The returned time is in time.UTC on the fast path and whatever time.Parse yields on the fallback; the instants agree in both cases.

func ParseIPv4 added in v2.4.0

func ParseIPv4[S byteSeq](s S) (netip.Addr, bool)

ParseIPv4 parses a dotted-decimal IPv4 address into a netip.Addr. It accepts exactly the IPv4 strings netip.ParseAddr does — four octets 0-255, no leading zeros, nothing before or after — and reports ok=false for everything else, including IPv6 forms. It never allocates, so []byte callers skip both the string conversion and netip's error construction.

IsIPv4 is the validate-only counterpart; it accepts the same strings.

func ParseIPv6 added in v2.4.0

func ParseIPv6[S byteSeq](s S) (netip.Addr, bool)

ParseIPv6 parses an IPv6 address into a netip.Addr. It accepts exactly the IPv6 strings netip.ParseAddr does — 16-bit hex fields, one optional "::", an optional embedded dotted-decimal IPv4 tail, and an optional non-empty "%zone" suffix — and reports ok=false for everything else, including plain IPv4 forms (use ParseIPv4 for those). The parse itself never allocates; only a present zone is materialized as a string because netip.Addr stores zones as strings.

IsIPv6 is the validate-only counterpart, but it follows net.ParseIP, which rejects zones. The two therefore disagree on zoned input by design: prefer ParseIPv6 when a zone is acceptable, IsIPv6 when it is not.

func ParseInt

func ParseInt[S byteSeq](s S) (int64, error)

ParseInt parses a decimal ASCII string or byte slice into an int64. Returns the parsed value and nil on success, else 0 and an error.

func ParseInt8

func ParseInt8[S byteSeq](s S) (int8, error)

ParseInt8 parses a decimal ASCII string or byte slice into an int8.

func ParseInt16

func ParseInt16[S byteSeq](s S) (int16, error)

ParseInt16 parses a decimal ASCII string or byte slice into an int16.

func ParseInt32

func ParseInt32[S byteSeq](s S) (int32, error)

ParseInt32 parses a decimal ASCII string or byte slice into an int32.

func ParseNativeInt added in v2.1.0

func ParseNativeInt[S byteSeq](s S) (int, error)

ParseNativeInt parses a decimal ASCII string or byte slice into an int.

func ParseNativeUint added in v2.1.0

func ParseNativeUint[S byteSeq](s S) (uint, error)

ParseNativeUint parses a decimal ASCII string or byte slice into a uint.

func ParseUint

func ParseUint[S byteSeq](s S) (uint64, error)

ParseUint parses a decimal ASCII string or byte slice into a uint64. It returns the parsed value and nil on success. If the input contains non-digit characters, it returns 0 and an error.

func ParseUint8

func ParseUint8[S byteSeq](s S) (uint8, error)

ParseUint8 parses a decimal ASCII string or byte slice into a uint8.

func ParseUint16

func ParseUint16[S byteSeq](s S) (uint16, error)

ParseUint16 parses a decimal ASCII string or byte slice into a uint16.

func ParseUint32

func ParseUint32[S byteSeq](s S) (uint32, error)

ParseUint32 parses a decimal ASCII string or byte slice into a uint32.

func ParseVendorSpecificContentType

func ParseVendorSpecificContentType(cType string, caseInsensitive ...bool) string

ParseVendorSpecificContentType check if content type is vendor specific and if it is parsable to any known types. If its not vendor specific then returns the original content type.

func ReadFile

func ReadFile(path string, fs http.FileSystem) ([]byte, error)

ReadFile returns the raw content of a file

func SecureToken

func SecureToken() string

SecureToken generates a secure token with 32 bytes of entropy. Panics if the random source fails. See GenerateSecureToken for details.

func SplitHostPort added in v2.5.0

func SplitHostPort[S byteSeq](hostport S) (host, port S, ok bool)

SplitHostPort splits "host:port", "[host]:port", and their %zone forms with net.SplitHostPort's exact rules, reporting failure as ok == false instead of a *net.AddrError; it accepts byte slices as well as strings, and the parts alias hostport.

func SplitTrimSeq added in v2.5.0

func SplitTrimSeq[S byteSeq](s S, sep byte) iter.Seq[S]

SplitTrimSeq iterates over the sep-separated elements of s with ASCII whitespace trimmed and empty elements skipped, as HTTP list fields are read (RFC 9110 Section 5.6.1); the elements alias s.

func StartTimeStampUpdater

func StartTimeStampUpdater()

StartTimeStampUpdater launches a background goroutine that updates the cached timestamp every second. It is safe to call multiple times and from multiple goroutines; only one updater runs at a time.

func StatusMessage

func StatusMessage(status int) string

StatusMessage returns the correct message for the provided HTTP statuscode

func StopTimeStampUpdater

func StopTimeStampUpdater()

StopTimeStampUpdater stops the background updater goroutine. Call this on app shutdown to avoid leaking goroutines. It is safe to call multiple times and from multiple goroutines.

func Timestamp

func Timestamp() uint32

Timestamp returns the current cached Unix timestamp (seconds). Call StartTimeStampUpdater() once at app startup for best performance.

func ToLower deprecated

func ToLower(b string) string

ToLower converts ascii string to lower-case.

Deprecated: use github.com/gofiber/utils/v2/strings.ToLower instead.

func ToLowerBytes deprecated

func ToLowerBytes(b []byte) []byte

ToLowerBytes converts an ASCII byte slice to lower-case in-place.

Deprecated: use github.com/gofiber/utils/v2/bytes.UnsafeToLower instead. This wrapper keeps backward compatibility by mutating the provided slice.

func ToString

func ToString(arg any, timeFormat ...string) string

ToString Change arg to string

func ToUpper deprecated

func ToUpper(b string) string

ToUpper converts ascii string to upper-case.

Deprecated: use github.com/gofiber/utils/v2/strings.ToUpper instead.

func ToUpperBytes deprecated

func ToUpperBytes(b []byte) []byte

ToUpperBytes converts an ASCII byte slice to upper-case in-place.

Deprecated: use github.com/gofiber/utils/v2/bytes.UnsafeToUpper instead. This wrapper keeps backward compatibility by mutating the provided slice.

func Trim

func Trim[S byteSeq](s S, cutset byte) S

Trim removes all leading and trailing occurrences of the byte cutset from s. Unlike strings/bytes.Trim, cutset is a single byte, not a set of characters.

func TrimLeft

func TrimLeft[S byteSeq](s S, cutset byte) S

TrimLeft removes all leading occurrences of the byte cutset from s. Unlike strings/bytes.TrimLeft, cutset is a single byte, not a set of characters.

func TrimRight

func TrimRight[S byteSeq](s S, cutset byte) S

TrimRight removes all trailing occurrences of the byte cutset from s. Unlike strings/bytes.TrimRight, cutset is a single byte, not a set of characters.

func TrimSpace

func TrimSpace[S byteSeq](s S) S

TrimSpace removes leading and trailing whitespace from a string or byte slice. This is an optimized version that's faster than strings/bytes.TrimSpace for ASCII strings. It removes the following ASCII whitespace characters: space, tab, newline, carriage return, vertical tab, and form feed.

func UUID

func UUID() string

UUID generates an universally unique identifier (UUID). This is an alias for UUIDv4 for backward compatibility.

func UUIDv4

func UUIDv4() string

UUIDv4 returns a Random (Version 4) UUID. The strength of the UUIDs is based on the strength of the crypto/rand package.

func UnsafeBytes

func UnsafeBytes(s string) []byte

UnsafeBytes returns a byte pointer without allocation.

func UnsafeString

func UnsafeString(b []byte) string

UnsafeString returns a string pointer without allocation

func Walk

func Walk(fs http.FileSystem, root string, walkFn filepath.WalkFunc) error

Walk walks the filesystem rooted at root, calling walkFn for each file or directory in the filesystem, including root. All errors that arise visiting files and directories are filtered by walkFn. The files are walked in lexical order.

Types

type CBORMarshal

type CBORMarshal func(v any) ([]byte, error)

CBORMarshal returns the CBOR encoding of v.

type CBORUnmarshal

type CBORUnmarshal func(data []byte, v any) error

CBORUnmarshal parses the CBOR-encoded data and stores the result in the value pointed to by v. If v is nil or not a pointer, Unmarshal returns an error.

type JSONMarshal

type JSONMarshal func(v any) ([]byte, error)

JSONMarshal returns the JSON encoding of v.

type JSONUnmarshal

type JSONUnmarshal func(data []byte, v any) error

JSONUnmarshal parses the JSON-encoded data and stores the result in the value pointed to by v. If v is nil or not a pointer, Unmarshal returns an InvalidUnmarshalError.

type MsgPackMarshal

type MsgPackMarshal func(v any) ([]byte, error)

MsgPackMarshal returns the MsgPack encoding of v.

type MsgPackUnmarshal

type MsgPackUnmarshal func(data []byte, v any) error

MsgPackUnmarshal parses the MsgPack-encoded data and stores the result in the value pointed to by v. If v is nil or not a pointer, Unmarshal returns an InvalidUnmarshalError.

type Signed

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type Unsigned

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type XMLMarshal

type XMLMarshal func(v any) ([]byte, error)

XMLMarshal returns the XML encoding of v.

type XMLUnmarshal

type XMLUnmarshal func(data []byte, v any) error

XMLUnmarshal parses the XML-encoded data and stores the result in the value pointed to by v. If v is nil or not a pointer, Unmarshal returns an InvalidUnmarshalError.

Directories

Path Synopsis
internal
Package simd provides SIMD-accelerated byte searching and validation primitives for the Fiber ecosystem: multi-needle scans, character-class scans, paired-byte scans, substring search, and ASCII validation.
Package simd provides SIMD-accelerated byte searching and validation primitives for the Fiber ecosystem: multi-needle scans, character-class scans, paired-byte scans, substring search, and ASCII validation.
Package swar provides SWAR (SIMD within a register) primitives for processing eight ASCII bytes per uint64 word.
Package swar provides SWAR (SIMD within a register) primitives for processing eight ASCII bytes per uint64 word.

Jump to

Keyboard shortcuts

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