Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(values): change the values directory to helpers #207

Merged
merged 2 commits into from
Apr 7, 2024
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 helpers/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func TestPipe(t *testing.T) {
// pipe functions
pipe2 := Pipe(
func(foo *foo) *foo {
foo.Name = "bar"
foo.Name = "bar" // nolint:goconst
return foo
},
func(foo *foo) *foo {
Expand Down
2 changes: 1 addition & 1 deletion values/proxy.go → helpers/proxy_value.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package values
package helpers

type Proxy[T any] struct {
value T
Expand Down
2 changes: 1 addition & 1 deletion values/proxy_test.go → helpers/proxy_value_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package values
package helpers

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion values/values.go → helpers/values.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package values
package helpers

// If returns trueVal if condition is true, otherwise falseVal.
//
Expand Down
7 changes: 1 addition & 6 deletions values/values_test.go → helpers/values_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package values
package helpers

import (
"errors"
Expand All @@ -9,11 +9,6 @@ import (
"github.com/stretchr/testify/assert"
)

type foo struct {
Name string
Age int
}

func TestTap_Struct(t *testing.T) {
f := &foo{Name: "foo"}

Expand Down
44 changes: 22 additions & 22 deletions ptr/ptr.go
Original file line number Diff line number Diff line change
@@ -1,111 +1,111 @@
// Deprecated: Use values.Ptr instead.
// Deprecated: Use helpers.Ptr instead.
package ptr

import (
"time"
)

// Deprecated: Use values.Ptr instead.
// Deprecated: Use helpers.Ptr instead.
func String(s string) *string {
return &s
}

// Deprecated: Use values.Ptr instead.
// Deprecated: Use helpers.Ptr instead.
func Bool(b bool) *bool {
return &b
}

// Deprecated: Use values.Ptr instead.
// Deprecated: Use helpers.Ptr instead.
func Int(i int) *int {
return &i
}

// Deprecated: Use values.Ptr instead.
// Deprecated: Use helpers.Ptr instead.
func Int8(i int8) *int8 {
return &i
}

// Deprecated: Use values.Ptr instead.
// Deprecated: Use helpers.Ptr instead.
func Int16(i int16) *int16 {
return &i
}

// Deprecated: Use values.Ptr instead.
// Deprecated: Use helpers.Ptr instead.
func Int32(i int32) *int32 {
return &i
}

// Deprecated: Use values.Ptr instead.
// Deprecated: Use helpers.Ptr instead.
func Int64(i int64) *int64 {
return &i
}

// Deprecated: Use values.Ptr instead.
// Deprecated: Use helpers.Ptr instead.
func Uint(u uint) *uint {
return &u
}

// Deprecated: Use values.Ptr instead.
// Deprecated: Use helpers.Ptr instead.
func Uint8(u uint8) *uint8 {
return &u
}

// Deprecated: Use values.Ptr instead.
// Deprecated: Use helpers.Ptr instead.
func Uint16(u uint16) *uint16 {
return &u
}

// Deprecated: Use values.Ptr instead.
// Deprecated: Use helpers.Ptr instead.
func Uint32(u uint32) *uint32 {
return &u
}

// Deprecated: Use values.Ptr instead.
// Deprecated: Use helpers.Ptr instead.
func Uint64(u uint64) *uint64 {
return &u
}

// Deprecated: Use values.Ptr instead.
// Deprecated: Use helpers.Ptr instead.
func Float32(f float32) *float32 {
return &f
}

// Deprecated: Use values.Ptr instead.
// Deprecated: Use helpers.Ptr instead.
func Float64(f float64) *float64 {
return &f
}

// Deprecated: Use values.Ptr instead.
// Deprecated: Use helpers.Ptr instead.
func Complex64(c complex64) *complex64 {
return &c
}

// Deprecated: Use values.Ptr instead.
// Deprecated: Use helpers.Ptr instead.
func Complex128(c complex128) *complex128 {
return &c
}

// Deprecated: Use values.Ptr instead.
// Deprecated: Use helpers.Ptr instead.
func Byte(b byte) *byte {
return &b
}

// Deprecated: Use values.Ptr instead.
// Deprecated: Use helpers.Ptr instead.
func Rune(r rune) *rune {
return &r
}

// Deprecated: Use values.Ptr instead.
// Deprecated: Use helpers.Ptr instead.
func Uintptr(u uintptr) *uintptr {
return &u
}

// Deprecated: Use values.Ptr instead.
// Deprecated: Use helpers.Ptr instead.
func Time(t time.Time) *time.Time {
return &t
}

// Deprecated: Use values.Ptr instead.
// Deprecated: Use helpers.Ptr instead.
func Duration(d time.Duration) *time.Duration {
return &d
}
42 changes: 21 additions & 21 deletions ptr/unptr.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,167 +2,167 @@ package ptr

import "time"

// Deprecated: Use values.Val instead.// Deprecated: Use values.Val instead.
// Deprecated: Use helpers.Val instead.// Deprecated: Use helpers.Val instead.
func UnString(s *string) (string, bool) {
if s == nil {
return "", false
}
return *s, true
}

// Deprecated: Use values.Val instead.
// Deprecated: Use helpers.Val instead.
func UnBool(b *bool) (bool, bool) {
if b == nil {
return false, false
}
return *b, true
}

// Deprecated: Use values.Val instead.
// Deprecated: Use helpers.Val instead.
func UnInt(i *int) (int, bool) {
if i == nil {
return 0, false
}
return *i, true
}

// Deprecated: Use values.Val instead.
// Deprecated: Use helpers.Val instead.
func UnInt8(i *int8) (int8, bool) {
if i == nil {
return 0, false
}
return *i, true
}

// Deprecated: Use values.Val instead.
// Deprecated: Use helpers.Val instead.
func UnInt16(i *int16) (int16, bool) {
if i == nil {
return 0, false
}
return *i, true
}

// Deprecated: Use values.Val instead.
// Deprecated: Use helpers.Val instead.
func UnInt32(i *int32) (int32, bool) {
if i == nil {
return 0, false
}
return *i, true
}

// Deprecated: Use values.Val instead.
// Deprecated: Use helpers.Val instead.
func UnInt64(i *int64) (int64, bool) {
if i == nil {
return 0, false
}
return *i, true
}

// Deprecated: Use values.Val instead.
// Deprecated: Use helpers.Val instead.
func UnUint(u *uint) (uint, bool) {
if u == nil {
return 0, false
}
return *u, true
}

// Deprecated: Use values.Val instead.
// Deprecated: Use helpers.Val instead.
func UnUint8(u *uint8) (uint8, bool) {
if u == nil {
return 0, false
}
return *u, true
}

// Deprecated: Use values.Val instead.
// Deprecated: Use helpers.Val instead.
func UnUint16(u *uint16) (uint16, bool) {
if u == nil {
return 0, false
}
return *u, true
}

// Deprecated: Use values.Val instead.
// Deprecated: Use helpers.Val instead.
func UnUint32(u *uint32) (uint32, bool) {
if u == nil {
return 0, false
}
return *u, true
}

// Deprecated: Use values.Val instead.
// Deprecated: Use helpers.Val instead.
func UnUint64(u *uint64) (uint64, bool) {
if u == nil {
return 0, false
}
return *u, true
}

// Deprecated: Use values.Val instead.
// Deprecated: Use helpers.Val instead.
func UnFloat32(f *float32) (float32, bool) {
if f == nil {
return 0, false
}
return *f, true
}

// Deprecated: Use values.Val instead.
// Deprecated: Use helpers.Val instead.
func UnFloat64(f *float64) (float64, bool) {
if f == nil {
return 0, false
}
return *f, true
}

// Deprecated: Use values.Val instead.
// Deprecated: Use helpers.Val instead.
func UnComplex64(c *complex64) (complex64, bool) {
if c == nil {
return 0, false
}
return *c, true
}

// Deprecated: Use values.Val instead.
// Deprecated: Use helpers.Val instead.
func UnComplex128(c *complex128) (complex128, bool) {
if c == nil {
return 0, false
}
return *c, true
}

// Deprecated: Use values.Val instead.
// Deprecated: Use helpers.Val instead.
func UnByte(b *byte) (byte, bool) {
if b == nil {
return 0, false
}
return *b, true
}

// Deprecated: Use values.Val instead.
// Deprecated: Use helpers.Val instead.
func UnRune(r *rune) (rune, bool) {
if r == nil {
return 0, false
}
return *r, true
}

// Deprecated: Use values.Val instead.
// Deprecated: Use helpers.Val instead.
func UnUintptr(u *uintptr) (uintptr, bool) {
if u == nil {
return 0, false
}
return *u, true
}

// Deprecated: Use values.Val instead.
// Deprecated: Use helpers.Val instead.
func UnTime(t *time.Time) (time.Time, bool) {
if t == nil {
return time.Time{}, false
}
return *t, true
}

// Deprecated: Use values.Val instead.
// Deprecated: Use helpers.Val instead.
func UnDuration(d *time.Duration) (time.Duration, bool) {
if d == nil {
return 0, false
Expand Down
Loading