![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
github.com/ibrt/golang-inject-clock
Clock module for the golang-inject framework.
This module injects a "clock" into Go context. It provides both a real and a mock implementation for use in tests. Beyond being useful by itself, it is also a minimal example of how to tie together modules using the golang-inject framework, and how to easily test implementations using the golang-fixtures test suites.
// main.go
package main
import (
"net/http"
"time"
"github.com/ibrt/golang-inject/injectz"
"github.com/ibrt/golang-inject-clock/clockz"
)
func main() {
injector, releaser := injectz.Initialize(clockz.Initializer)
defer releaser()
middleware := injectz.NewMiddleware(injector)
mux := http.NewServeMux()
mux.Handle("/", middleware(http.HandlerFunc(handler)))
_ = http.ListenAndServe(":3000", mux)
}
func handler(w http.ResponseWriter, r *http.Request) {
_, _ = w.Write([]byte(clockz.Get(r.Context()).Now().Format(time.RFC3339Nano)))
}
// main_test.go
package main
import (
"context"
"net/http"
"net/http/httptest"
"testing"
"time"
"github.com/ibrt/golang-fixtures/fixturez"
"github.com/ibrt/golang-inject-clock/clockz/testclockz"
"github.com/stretchr/testify/require"
)
var (
_ fixturez.Suite = &Suite{}
)
type Suite struct {
*fixturez.DefaultConfigMixin
Clock *testclockz.MockHelper
}
func TestSuite(t *testing.T) {
fixturez.RunSuite(t, &Suite{})
}
func (s *Suite) TestHandler(ctx context.Context, t *testing.T) {
const nowStr = "2009-11-18T08:04:34.829482969Z"
now, err := time.Parse(time.RFC3339Nano, nowStr)
require.NoError(t, err)
s.Clock.Mock.Set(now)
w := httptest.NewRecorder()
r := httptest.NewRequest("GET", "/", nil).WithContext(ctx)
handler(w, r)
require.Equal(t, http.StatusOK, w.Code)
require.Equal(t, nowStr, w.Body.String())
}
Contributions are welcome, please check in on proposed implementation before sending a PR. You can validate your changes
using the ./test.sh
script.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.