diff --git a/README.md b/README.md index 3f78061..fa5c219 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # pkg -![Project status](https://img.shields.io/badge/version-5.5.0-green.svg) +![Project status](https://img.shields.io/badge/version-5.5.1-green.svg) [![Build Status](https://travis-ci.org/go-playground/pkg.svg?branch=master)](https://travis-ci.org/go-playground/pkg) [![Coverage Status](https://coveralls.io/repos/github/go-playground/pkg/badge.svg?branch=master)](https://coveralls.io/github/go-playground/pkg?branch=master) [![GoDoc](https://godoc.org/github.com/go-playground/pkg?status.svg)](https://pkg.go.dev/mod/github.com/go-playground/pkg/v5) diff --git a/go.mod b/go.mod index f2795bb..07c2e50 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,7 @@ module github.com/go-playground/pkg/v5 require ( - github.com/go-playground/assert/v2 v2.0.1 + github.com/go-playground/assert/v2 v2.2.0 github.com/go-playground/form/v4 v4.2.0 ) diff --git a/go.sum b/go.sum index 15a83ba..0e0881a 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,6 @@ github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/form/v4 v4.2.0 h1:N1wh+Goz61e6w66vo8vJkQt+uwZSoLz50kZPJWR8eic= github.com/go-playground/form/v4 v4.2.0/go.mod h1:q1a2BY+AQUUzhl6xA/6hBetay6dEIhMHjgvJiGo6K7U= diff --git a/sync/mutex.go b/sync/mutex.go index 70e6a67..7c28f5a 100644 --- a/sync/mutex.go +++ b/sync/mutex.go @@ -1,11 +1,11 @@ //go:build go1.18 -package sync +package syncext import ( "sync" - "github.com/go-playground/pkg/v5/values/result" + resultext "github.com/go-playground/pkg/v5/values/result" ) // NewMutex creates a new Mutex for use. @@ -45,11 +45,11 @@ func (m *Mutex[T]) Unlock() { // TryLock tries to lock Mutex and reports whether it succeeded. // If it does the value is returned for use in the Ok result otherwise Err with empty value. -func (m *Mutex[T]) TryLock() result.Result[T, struct{}] { +func (m *Mutex[T]) TryLock() resultext.Result[T, struct{}] { if m.m.TryLock() { - return result.Ok[T, struct{}](m.value) + return resultext.Ok[T, struct{}](m.value) } else { - return result.Err[T, struct{}](struct{}{}) + return resultext.Err[T, struct{}](struct{}{}) } } @@ -89,11 +89,11 @@ func (m *RWMutex[T]) Unlock() { // TryLock tries to lock RWMutex and returns the value in the Ok result if successful. // If it does the value is returned for use in the Ok result otherwise Err with empty value. -func (m *RWMutex[T]) TryLock() result.Result[T, struct{}] { +func (m *RWMutex[T]) TryLock() resultext.Result[T, struct{}] { if m.rw.TryLock() { - return result.Ok[T, struct{}](m.value) + return resultext.Ok[T, struct{}](m.value) } else { - return result.Err[T, struct{}](struct{}{}) + return resultext.Err[T, struct{}](struct{}{}) } } @@ -121,10 +121,10 @@ func (m *RWMutex[T]) RUnlock() { // TryRLock tries to lock RWMutex for reading and returns the value in the Ok result if successful. // If it does the value is returned for use in the Ok result otherwise Err with empty value. -func (m *RWMutex[T]) TryRLock() result.Result[T, struct{}] { +func (m *RWMutex[T]) TryRLock() resultext.Result[T, struct{}] { if m.rw.TryRLock() { - return result.Ok[T, struct{}](m.value) + return resultext.Ok[T, struct{}](m.value) } else { - return result.Err[T, struct{}](struct{}{}) + return resultext.Err[T, struct{}](struct{}{}) } } diff --git a/sync/mutex_test.go b/sync/mutex_test.go index 5226bb7..bfd8a56 100644 --- a/sync/mutex_test.go +++ b/sync/mutex_test.go @@ -1,6 +1,6 @@ //go:build go1.18 -package sync +package syncext import ( "testing" diff --git a/values/option/option.go b/values/option/option.go index 610fbd7..4e6ed6b 100644 --- a/values/option/option.go +++ b/values/option/option.go @@ -1,7 +1,7 @@ //go:build go1.18 // +build go1.18 -package option +package optionext import ( "database/sql" @@ -16,8 +16,7 @@ import ( // // nil is usually used on Go however this has two problems: // 1. Checking if the return values is nil is NOT enforced and can lead to panics. -// 2. Using nil is not good enough when nil itself is a valid values. -// +// 2. Using nil is not good enough when nil itself is a valid value. type Option[T any] struct { value T isSome bool diff --git a/values/option/option_test.go b/values/option/option_test.go index 6c5439e..19d4f9c 100644 --- a/values/option/option_test.go +++ b/values/option/option_test.go @@ -1,7 +1,7 @@ //go:build go1.18 // +build go1.18 -package option +package optionext import ( "encoding/json" diff --git a/values/result/result.go b/values/result/result.go index 85644f8..f9960b1 100644 --- a/values/result/result.go +++ b/values/result/result.go @@ -1,7 +1,7 @@ //go:build go1.18 // +build go1.18 -package result +package resultext // Result represents the result of an operation that is successful or not. type Result[T, E any] struct { diff --git a/values/result/result_test.go b/values/result/result_test.go index 0b42fac..ce3e719 100644 --- a/values/result/result_test.go +++ b/values/result/result_test.go @@ -1,7 +1,7 @@ //go:build go1.18 // +build go1.18 -package result +package resultext import ( "errors"