Giter Club home page Giter Club logo

forego's Introduction

forego

THIS MODULE IS STILL A WORK IN PROGRESS AND NOT READY FOR USE

Go framework to simplify testing, http/ws API, authentication/authorization, etc...

ctx

We expand from context.Context with few features and quality of life:

  • mostly we assume we always want a ctx.C everywhere: because tracing, span, tags, loggers, etc
  • contexts are not just for cancel, they can store environment and even configurations

c ctx.C instead of ctx context.Context

Just cosmetic, I find it better to keep the context to the minimum, and used everywhere. And we never really used c for connections, clients or channels anyways, do we?

ctx.Err

Having a wrapping error that provide a stack trace has proven formidable when working with libraries. The logger expand any logged error accordingly. No longer guess from there the error come from, but still no extra log messages or long stack traces.

Tags and ctx/log

Each context has a bag of tags, which can added along the way. Those will be printed in each log messages, which make it particularly useful for things like CorrelationID, auth or any context which will help debugging from a log message.

It also make it coherent when using other libraries, since they will still carry over the context.

All logging is JSON lines, e.g.:

{"level":"debug","src":"github.com/Aize-Public/forego/http/server.go:83","time":"2023-06-01T07:18:31.007411033+02:00","message":"listening to :8080","tags":{"service":"viewer"}}

May be wise to use a log viewer like https://github.com/ohait/jl

test

Having a good testing library, means less to write, and better results.

All the tests will generate a log message when they succeed based on the arguments, most of the time this is enough to understand the test.

E.g. with this code:

  err := foo(123)
  test.NoError(t, err)

The following log message is generated:

    my_test.go:123 ok: foo(123)

ast parsing

Some functions like test.NoError() and test.Assert() will log the code which they have been invoked with. E.g.:

  func TestX(t *testing.T) {
    everything := 42
    test.Assert(t, everything > 7*3)
  }

It will log a message like:

ok: everything > 7*3

In the case of error, it will print what was the function assigning to the error

api

Framework to automatically create bindings and documentation for APIs:

  • no more test of bindings, just test the business logic
  • OpenAPI automatically generated
  • tight integration with http, WebSocket and other streaming libraries
  • simple and no boiler plate

TODO

forego's People

Contributors

ohait avatar hakonra avatar brunoaize avatar aovtails avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.