Migrate package imports from next.orly.dev to new orly domain structure; add new varint and binary encoders with comprehensive tests; enhance existing tag and envelope implementations with additional methods, validations, and test coverage; introduce shared test.sh script for streamlined testing across modules.

This commit is contained in:
2025-08-31 16:52:24 +01:00
parent 94383f29e9
commit 91d95c6f1a
202 changed files with 12803 additions and 420 deletions

View File

@@ -0,0 +1,60 @@
// Package apputil provides utility functions for file and directory operations.
package apputil
import (
"os"
"path/filepath"
"lol.mleku.dev/chk"
)
// EnsureDir checks if a file could be written to a path and creates the
// necessary directories if they don't exist. It ensures that all parent
// directories in the path are created with the appropriate permissions.
//
// # Parameters
//
// - fileName: The full path to the file for which directories need to be
// created.
//
// Expected behavior:
//
// - Extracts the directory path from the fileName.
//
// - Checks if the directory exists.
//
// - If the directory doesn't exist, creates it and all parent directories.
func EnsureDir(fileName string) (merr error) {
dirName := filepath.Dir(fileName)
if _, err := os.Stat(dirName); chk.E(err) {
merr = os.MkdirAll(dirName, os.ModePerm)
if chk.E(merr) {
return
}
return
}
return
}
// FileExists reports whether the named file or directory exists.
//
// # Parameters
//
// - filePath: The full path to the file or directory to check.
//
// Returns:
//
// - bool: true if the file or directory exists, false otherwise.
//
// Behavior:
//
// - Uses os.Stat to check if the file or directory exists.
//
// - Returns true if the file exists and can be accessed.
//
// - Returns false if the file doesn't exist or cannot be accessed due to
// permissions.
func FileExists(filePath string) bool {
_, e := os.Stat(filePath)
return e == nil
}

View File

@@ -1,12 +1,9 @@
package bufpool
import (
"fmt"
"sync"
"unsafe"
"lol.mleku.dev/log"
"next.orly.dev/pkg/utils/units"
"utils.orly/units"
)
const (
@@ -22,12 +19,12 @@ var Pool = sync.Pool{
New: func() interface{} {
// Create a new buffer when the pool is empty
b := make([]byte, 0, BufferSize)
log.T.C(
func() string {
ptr := unsafe.SliceData(b)
return fmt.Sprintf("creating buffer at: %p", ptr)
},
)
// log.T.C(
// func() string {
// ptr := unsafe.SliceData(b)
// return fmt.Sprintf("creating buffer at: %p", ptr)
// },
// )
return B(b)
},
}
@@ -41,12 +38,12 @@ var Pool = sync.Pool{
// // Use buf...
func Get() B {
b := Pool.Get().(B)
log.T.C(
func() string {
ptr := unsafe.SliceData(b)
return fmt.Sprintf("getting buffer at: %p", ptr)
},
)
// log.T.C(
// func() string {
// ptr := unsafe.SliceData(b)
// return fmt.Sprintf("getting buffer at: %p", ptr)
// },
// )
return b
}
@@ -57,23 +54,23 @@ func Put(b B) {
(b)[i] = 0
}
b = b[:0]
log.T.C(
func() string {
ptr := unsafe.SliceData(b)
return fmt.Sprintf("returning to buffer: %p", ptr)
},
)
// log.T.C(
// func() string {
// ptr := unsafe.SliceData(b)
// return fmt.Sprintf("returning to buffer: %p", ptr)
// },
// )
Pool.Put(b)
}
// PutBytes returns a buffer was not necessarily created by Get().
func PutBytes(b []byte) {
log.T.C(
func() string {
ptr := unsafe.SliceData(b)
return fmt.Sprintf("returning bytes to buffer: %p", ptr)
},
)
// log.T.C(
// func() string {
// ptr := unsafe.SliceData(b)
// return fmt.Sprintf("returning bytes to buffer: %p", ptr)
// },
// )
b = b[:0]
Put(b)
}

24
pkg/utils/go.mod Normal file
View File

@@ -0,0 +1,24 @@
module utils.orly
go 1.25.0
require (
encoders.orly v0.0.0-00010101000000-000000000000
lol.mleku.dev v1.0.2
)
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b // indirect
golang.org/x/sys v0.35.0 // indirect
)
replace (
crypto.orly => ./pkg/crypto
encoders.orly => ../encoders
interfaces.orly => ../interfaces
next.orly.dev => ../../
)

17
pkg/utils/go.sum Normal file
View File

@@ -0,0 +1,17 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b h1:DXr+pvt3nC887026GRP39Ej11UATqWDmWuS99x26cD0=
golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b/go.mod h1:4QTo5u+SEIbbKW1RacMZq1YEfOBqeXa19JeshGi+zc4=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
lol.mleku.dev v1.0.2 h1:bSV1hHnkmt1hq+9nSvRwN6wgcI7itbM3XRZ4dMB438c=
lol.mleku.dev v1.0.2/go.mod h1:DQ0WnmkntA9dPLCXgvtIgYt5G0HSqx3wSTLolHgWeLA=
lukechampine.com/frand v1.5.1 h1:fg0eRtdmGFIxhP5zQJzM1lFDbD6CUfu/f+7WgAZd5/w=
lukechampine.com/frand v1.5.1/go.mod h1:4VstaWc2plN4Mjr10chUD46RAVGWhpkZ5Nja8+Azp0Q=

View File

@@ -7,9 +7,9 @@ import (
"fmt"
"net/url"
"encoders.orly/ints"
"lol.mleku.dev/chk"
"lol.mleku.dev/log"
"next.orly.dev/pkg/encoders/ints"
)
var (

View File

@@ -3,7 +3,7 @@ package pointers
import (
"time"
"next.orly.dev/pkg/encoders/timestamp"
"encoders.orly/timestamp"
)
// PointerToValue is a generic interface (type constraint) to refer to any