Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -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
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
22 changes: 11 additions & 11 deletions sync/mutex.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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{}{})
}
}

Expand Down Expand Up @@ -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{}{})
}
}

Expand Down Expand Up @@ -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{}{})
}
}
2 changes: 1 addition & 1 deletion sync/mutex_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build go1.18

package sync
package syncext

import (
"testing"
Expand Down
5 changes: 2 additions & 3 deletions values/option/option.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//go:build go1.18
// +build go1.18

package option
package optionext

import (
"database/sql"
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion values/option/option_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//go:build go1.18
// +build go1.18

package option
package optionext

import (
"encoding/json"
Expand Down
2 changes: 1 addition & 1 deletion values/result/result.go
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion values/result/result_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//go:build go1.18
// +build go1.18

package result
package resultext

import (
"errors"
Expand Down