Skip to content

Commit

Permalink
Merge pull request #66 from IBM/cleue-add-try-catch-for-single-value-…
Browse files Browse the repository at this point in the history
…return

fix: remove File.GetName and add Join for convenience
  • Loading branch information
CarstenLeue authored Oct 11, 2023
2 parents af2915d + 1eefc28 commit c629d18
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 1 addition & 2 deletions context/readerioeither/file/tempfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"os"

RIOE "github.com/IBM/fp-go/context/readerioeither"
FL "github.com/IBM/fp-go/file"
F "github.com/IBM/fp-go/function"
IO "github.com/IBM/fp-go/io"
IOF "github.com/IBM/fp-go/io/file"
Expand All @@ -32,7 +31,7 @@ var (
// destroy handler
onReleaseTempFile = F.Flow4(
IOF.Close[*os.File],
IO.Map(FL.GetName),
IO.Map((*os.File).Name),
RIOE.FromIO[string],
RIOE.Chain(Remove),
)
Expand Down
10 changes: 6 additions & 4 deletions file/getters.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@

package file

import "os"
import "path/filepath"

// GetName is the getter for the `Name` property of [os.File]
func GetName(f *os.File) string {
return f.Name()
// Join appends a filename to a root path
func Join(name string) func(root string) string {
return func(root string) string {
return filepath.Join(root, name)
}
}
3 changes: 1 addition & 2 deletions ioeither/file/tempfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package file
import (
"os"

FL "github.com/IBM/fp-go/file"
F "github.com/IBM/fp-go/function"
IO "github.com/IBM/fp-go/io"
IOF "github.com/IBM/fp-go/io/file"
Expand All @@ -33,7 +32,7 @@ var (
// destroy handler
onReleaseTempFile = F.Flow4(
IOF.Close[*os.File],
IO.Map(FL.GetName),
IO.Map((*os.File).Name),
IOE.FromIO[error, string],
IOE.Chain(Remove),
)
Expand Down

0 comments on commit c629d18

Please sign in to comment.