Go to file
Mike Schwörer 36b092774d
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 2m12s
v0.0.550 ArrMapSum
2024-12-26 00:23:24 +01:00
_data v0.0.184 re-add missing array methods from merge commit 56684b2c0b 2023-07-19 19:29:59 +02:00
.gitea/workflows v0.0.318 add failure mail to testx.yml 2023-11-13 15:34:58 +01:00
.idea v0.0.400 added CommentTrimmer and DBOptions to sq 2024-03-09 14:59:32 +01:00
bfcodegen v0.0.536 revert bfcodegen changes 2024-10-22 09:57:06 +02:00
cmdext try to fix test 'cmdext:TestFailOnStderr' 2023-09-25 18:04:56 +02:00
confext v0.0.287 fix bug in confext::ApplyEnvOverrides if a struct env key exists in the os.env 2023-10-12 10:02:42 +02:00
cryptext v0.0.374 ppwgen 2024-01-14 01:37:38 +01:00
ctxext v0.0.521 ctxext 2024-10-05 01:06:36 +02:00
cursortoken v0.0.548 2024-12-09 17:39:35 +01:00
dataext v0.0.546 Fix ginext json-parse error when the bufferedReader was read beforehand 2024-11-28 12:06:57 +01:00
enums v0.0.402 add PackageName() and TypeName() to enums_codegen 2024-03-10 12:49:31 +01:00
exerr v0.0.545 2024-11-27 13:21:45 +01:00
fsext v0.0.289 fsext 2023-10-26 11:29:08 +02:00
ginext v0.0.546 Fix ginext json-parse error when the bufferedReader was read beforehand 2024-11-28 12:06:57 +01:00
gojson v0.0.512 2024-09-15 21:25:21 +02:00
googleapi fix tests 2023-12-17 14:04:35 +01:00
imageext v0.0.495 2024-08-07 14:00:02 +02:00
langext v0.0.550 ArrMapSum 2024-12-26 00:23:24 +01:00
mathext v0.0.482 mathext.Percentile 2024-07-12 16:33:42 +02:00
mongoext v0.0.455 add proper json/bson marshalling to exerr [severity|type|category] 2024-05-16 15:38:42 +02:00
pagination v0.0.473 add ctx to wmo.FilterQuery|Sort|Pagination 2024-06-14 17:24:59 +02:00
reflectext v0.0.549 2024-12-10 13:24:06 +01:00
rext v0.0.244 2023-08-18 13:27:02 +02:00
rfctime v0.0.434 2024-04-15 10:43:26 +02:00
scn v0.0.353 add scn.sendmessage 2024-01-04 12:38:03 +01:00
sq v0.0.522 2024-10-05 01:12:00 +02:00
syncext v0.0.315 atomic 2023-11-12 03:10:55 +01:00
termext Fix tests 2023-08-14 16:32:39 +02:00
timeext v0.0.509 2024-08-26 14:35:49 +02:00
totpext remove ginext/mongoext (no-dep lib) 2022-10-27 16:07:42 +02:00
tst v0.0.383 sq.InsertMultiple 2024-02-09 15:17:51 +01:00
wmo v0.0.547 allow calling ListWithCount with pageSize=0 2024-12-08 18:04:04 +01:00
wpdf v0.0.504 2024-08-07 19:44:45 +02:00
zipext remove ginext/mongoext (no-dep lib) 2022-10-27 16:07:42 +02:00
.gitignore copy langext & timeext from bm 2022-10-27 16:00:57 +02:00
go.mod v0.0.550 ArrMapSum 2024-12-26 00:23:24 +01:00
go.sum v0.0.550 ArrMapSum 2024-12-26 00:23:24 +01:00
goextVersion.go v0.0.550 ArrMapSum 2024-12-26 00:23:24 +01:00
LICENSE copy langext & timeext from bm 2022-10-27 16:00:57 +02:00
Makefile try to fix test 'cmdext:TestFailOnStderr' 2023-09-25 18:04:56 +02:00
README.md v0.0.521 ctxext 2024-10-05 01:06:36 +02:00
TODO.md v0.0.402 add PackageName() and TypeName() to enums_codegen 2024-03-10 12:49:31 +01:00

BFB goext library

A collection of general & useful library methods

This should not have any heavy dependencies (gin, mongo, etc) and add missing basic language features...

Potentially needs export GOPRIVATE="gogs.mikescher.com"

Packages:

Name Maintainer Description
langext Mike General uttility/helper functions, (everything thats missing from go standard library)
mathext Mike Utility/Helper functions for math
cryptext Mike Utility/Helper functions for encryption
syncext Mike Utility/Helper funtions for multi-threading / mutex / channels
dataext Mike Various useful data structures
zipext Mike Utility for zip/gzip/tar etc
reflectext Mike Utility for golang reflection
fsext Mike Utility for filesytem access
ctxext Mike Utility for context.Context
mongoext Mike Utility/Helper functions for mongodb (kinda abandoned)
cursortoken Mike MongoDB cursortoken implementation
pagination Mike Pagination implementation
totpext Mike Implementation of TOTP (2-Factor-Auth)
termext Mike Utilities for terminals (mostly color output)
confext Mike Parses environment configuration into structs
cmdext Mike Runner for external commands/processes
sq Mike Utility functions for sql based databases (primarily sqlite)
tst Mike Utility functions for unit tests
rfctime Mike Classes for time seriallization, with different marshallign method for mongo and json
gojson Mike Same interface for marshalling/unmarshalling as go/json, except with proper serialization of null arrays/maps
bfcodegen Mike Various codegen tools (run via go generate)
rext Mike Regex Wrapper, wraps regexp with a better interface
wmo Mike Mongo Wrapper, wraps mongodb with a better interface
scn Mike SimpleCloudNotifier

Usage:

exerr

  • see mongoext/builder.go for full info

Short summary:

  • An better error package with metadata, listener, api-output and error-traces
  • Initialize with exerr.Init()
  • Never return err direct, always use exerr.Wrap(err, "...") - add metadata where applicable
  • at the end either Print(), Fatal() or Output() your error (print = stdout, fatal = panic, output = json API response)
  • You can add listeners with exerr.RegisterListener(), and save the full errors to a db or smth

wmo

  • A typed wrapper around the official mongo-go-driver
  • Use wmo.W[...](...) to wrap the collections and type-ify them
  • The new collections have all the usual methods, but types
  • Also they have List() and Paginate() methods for paginated listings (witehr with a cursortoken or page/limit)
  • Register additional hooks with WithDecodeFunc, WithUnmarshalHook, WithMarshalHook, WithModifyingPipeline, WithModifyingPipelineFunc
  • List(), Paginate(), etc support filter interfaces
    • Rule(s) of thumb:
      • filter the results in the filter interface
      • sort the results in the sort function of the filter interface
      • add joins ($lookup's) in the WithModifyingPipelineFunc/WithModifyingPipeline

ginext

  • A wrapper around gin-gonic/gin
  • create the gin engine with ginext.NewEngine
  • Add routes with engine.Routes()...
    • .Use(..) adds a middleware
    • .Group(..) adds a group
    • .Get().Handle(..) adds a handler
  • Handler return values (in contract to ginext) - values implement the ginext.HTTPResponse interface
  • Every handler starts with something like:
func (handler Handler) CommunityMetricsValues(pctx ginext.PreContext) ginext.HTTPResponse {
    type communityURI struct {
        Version     string             `uri:"version"`
        CommunityID models.CommunityID `uri:"cid"`
    }
    type body struct {
        UserID  models.UserID  `json:"userID"`
        EventID models.EventID `json:"eventID"`
    }

    var u uri
    var b body
    ctx, gctx, httpErr := pctx.URI(&u).Body(&b).Start() // can have more unmarshaller, like header, form, etc
    if httpErr != nil {
    	return *httpErr
    }
    defer ctx.Cancel()

    // do stuff
}

sq

  • TODO (like mongoext for sqlite/sql databases)