Skip to content

Commit

Permalink
upgrade CI ti go 1.18.4
Browse files Browse the repository at this point in the history
  • Loading branch information
medmouine committed Aug 18, 2022
1 parent 85d12d9 commit 0f6be4f
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/setup-go@v2
with:
stable: 'false'
go-version: '1.18.0-beta1'
go-version: '1.18.4'
- name: Prepare
run: |
go get -u golang.org/x/lint/golint
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/setup-go@v2
with:
stable: 'false'
go-version: '1.18.0-beta1'
go-version: '1.18.4'
- name: Test
run: |
go test -v ./... -coverprofile=coverage.txt -covermode=atomic
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ fabric.properties
.idea/**/markdown-navigator.xml
.idea/**/markdown-navigator-enh.xml
.idea/**/markdown-navigator/
**/.idea

# Cache file creation bug
# See https://youtrack.jetbrains.com/issue/JBR-2257
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

<img src="./img/gomad-logo.png" alt="drawing" width="600"/>

Note: The package is currently available on pkg.go.dev and ready to use with Golang 1.18-alpha. I am waiting for the stable release of v1.18 to officially release Gomad v1.0.0.

# **GOMAD**: Functional Patterns in Golang
- [Prerequisites](#prerequisites)
- [Install](#install)
Expand Down
8 changes: 4 additions & 4 deletions either/either_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ func TestEither_MaybeLeft(t *testing.T) {
if !got.IsSome() {
t.Errorf("MaybeLeft() = %v, want %v", got.IsSome(), true)

if !reflect.DeepEqual(got.Unwrap(), "foo") {
t.Errorf("MaybeLeft() = %v, want %v", got.Unwrap(), "foo")
if !reflect.DeepEqual(*got.Unwrap(), "foo") {
t.Errorf("MaybeLeft() = %v, want %v", *got.Unwrap(), "foo")
}
}

Expand All @@ -301,8 +301,8 @@ func TestEither_MaybeRight(t *testing.T) {
if !got.IsSome() {
t.Errorf("MaybeRight() = %v, want %v", got.IsSome(), true)

if !reflect.DeepEqual(got.Unwrap(), "foo") {
t.Errorf("MaybeRight() = %v, want %v", got.Unwrap(), "foo")
if !reflect.DeepEqual(*got.Unwrap(), "foo") {
t.Errorf("MaybeRight() = %v, want %v", *got.Unwrap(), "foo")
}
}

Expand Down
4 changes: 2 additions & 2 deletions identity/identity.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package identity

func Identity[T any](i T) *T {
return &i
func Identity[T any](i T) T {
return i
}
1 change: 1 addition & 0 deletions maybe/maybe.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func (m maybe[T]) IsNil() bool {
func (m maybe[T]) OrElse(f func() T) *T {
if m.IsNil() {
v := f()

return &v
}

Expand Down
50 changes: 25 additions & 25 deletions maybe/maybe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ func TestMaybe_Just(t *testing.T) {
integer := 123
gotInt := Just(integer)

if !reflect.DeepEqual(gotInt.Unwrap(), integer) {
t.Errorf("Just() = %v, want %v", gotInt.Unwrap(), integer)
if !reflect.DeepEqual(*gotInt.Unwrap(), integer) {
t.Errorf("Just() = %v, want %v", *gotInt.Unwrap(), integer)
}

if !reflect.DeepEqual(gotInt.IsNil(), false) {
Expand All @@ -24,15 +24,15 @@ func TestMaybe_Just(t *testing.T) {
_string := "abc"
gotStr := Just(_string)

if !reflect.DeepEqual(gotStr.Unwrap(), _string) {
t.Errorf("Just() = %v, want %v", gotStr.Unwrap(), _string)
if !reflect.DeepEqual(*gotStr.Unwrap(), _string) {
t.Errorf("Just() = %v, want %v", *gotStr.Unwrap(), _string)
}

_slice := []int{1, 2, 3}
gotSlice := Just(_slice)

if !reflect.DeepEqual(gotSlice.Unwrap(), _slice) {
t.Errorf("Just() = %v, want %v", gotSlice.Unwrap(), _slice)
if !reflect.DeepEqual(*gotSlice.Unwrap(), _slice) {
t.Errorf("Just() = %v, want %v", *gotSlice.Unwrap(), _slice)
}
}

Expand All @@ -49,14 +49,14 @@ func TestMaybe_Of(t *testing.T) {
t.Parallel()

integer := 123
gotInteger := Of(&integer)
gotInt := Of(&integer)

if !reflect.DeepEqual(gotInteger.Unwrap(), integer) {
t.Errorf("Of() = %v, want %v", gotInteger.Unwrap(), integer)
if !reflect.DeepEqual(*gotInt.Unwrap(), integer) {
t.Errorf("Of() = %v, want %v", *gotInt.Unwrap(), integer)
}

if gotInteger.IsNil() {
t.Errorf("Of() = %v, want %v", gotInteger.IsNil(), false)
if gotInt.IsNil() {
t.Errorf("Of() = %v, want %v", gotInt.IsNil(), false)
}

gotNil := Of[int](nil)
Expand All @@ -82,8 +82,8 @@ func TestMaybe_Apply(t *testing.T) {
t.Errorf("Apply() called = %v, want %v", called, true)
}

if !reflect.DeepEqual(m.Unwrap(), integer) {
t.Errorf("Apply() = %v, want %v", m.Unwrap(), integer)
if !reflect.DeepEqual(*m.Unwrap(), integer) {
t.Errorf("Apply() = %v, want %v", *m.Unwrap(), integer)
}

called2 := false
Expand All @@ -103,8 +103,8 @@ func TestMaybe_Map(t *testing.T) {
got := Just(1).Map(func(v int) int {
return v + 3
})
if !reflect.DeepEqual(got.Unwrap(), 4) {
t.Errorf("Map() = %v, want %v", got.Unwrap(), 4)
if !reflect.DeepEqual(*got.Unwrap(), 4) {
t.Errorf("Map() = %v, want %v", *got.Unwrap(), 4)
}

if !got.IsSome() {
Expand All @@ -122,8 +122,8 @@ func TestMaybe_Map(t *testing.T) {
func TestMaybe_Unwrap(t *testing.T) {
t.Parallel()

if got := Just(1).Unwrap(); !reflect.DeepEqual(got, 1) {
t.Errorf("Unwrap() = %v, want %v", got, 1)
if got := Just(1).Unwrap(); !reflect.DeepEqual(*got, 1) {
t.Errorf("Unwrap() = %v, want %v", *got, 1)
}

defer func() {
Expand All @@ -141,27 +141,27 @@ func TestMaybe_OrElse(t *testing.T) {
got := None[int]().OrElse(func() int {
return 3
})
if !reflect.DeepEqual(got, 3) {
t.Errorf("OrElse() = %v, want %v", got, 3)
if !reflect.DeepEqual(*got, 3) {
t.Errorf("OrElse() = %v, want %v", *got, 3)
}

got2 := Just(1).OrElse(func() int {
return 3
})
if !reflect.DeepEqual(got2, 1) {
t.Errorf("OrElse() = %v, want %v", got2, 1)
if !reflect.DeepEqual(*got2, 1) {
t.Errorf("OrElse() = %v, want %v", *got2, 1)
}
}

func TestMaybe_Or(t *testing.T) {
t.Parallel()

if got := None[int]().Or(3); !reflect.DeepEqual(got, 3) {
t.Errorf("Or() = %v, want %v", got, 3)
if got := None[int]().Or(3); !reflect.DeepEqual(*got, 3) {
t.Errorf("Or() = %v, want %v", *got, 3)
}

if got2 := Just(1).Or(3); !reflect.DeepEqual(got2, 1) {
t.Errorf("Or() = %v, want %v", got2, 1)
if got2 := Just(1).Or(3); !reflect.DeepEqual(*got2, 1) {
t.Errorf("Or() = %v, want %v", *got2, 1)
}
}

Expand Down
4 changes: 3 additions & 1 deletion result/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ func FromMaybe[T any](m maybe.Maybe[T], err error) Result[T] {
if m.IsNil() {
return Err[T](err)
}
return Ok(m.Unwrap())

v := m.Unwrap()
return Ok[T](*v)
}

/*
Expand Down

0 comments on commit 0f6be4f

Please sign in to comment.