From 06d81f16823ddd1ab4c165cefb38824458254970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Thu, 26 Oct 2023 11:29:08 +0200 Subject: [PATCH] v0.0.289 fsext --- README.md | 59 +++++++++++++++++++++++++------------------------ fsext/exists.go | 36 ++++++++++++++++++++++++++++++ go.mod | 2 +- go.sum | 2 ++ goextVersion.go | 4 ++-- 5 files changed, 71 insertions(+), 32 deletions(-) create mode 100644 fsext/exists.go diff --git a/README.md b/README.md index 6ea405f..ef884ec 100644 --- a/README.md +++ b/README.md @@ -10,32 +10,33 @@ Potentially needs `export GOPRIVATE="gogs.mikescher.com"` ### Packages: -| Name | Maintainer | Description | -|--------------|------------|---------------------------------------------------------------------------------------------------------------| -| langext | Mike | General uttility/helper functions, (everything thats missing from go standard library) | -| mathext | Mike | Utility/Helper functions for math | -| cryptext | Mike | Utility/Helper functions for encryption | -| syncext | Mike | Utility/Helper funtions for multi-threading / mutex / channels | -| dataext | Mike | Various useful data structures | -| zipext | Mike | Utility for zip/gzip/tar etc | -| reflectext | Mike | Utility for golagn reflection | -| | | | -| mongoext | Mike | Utility/Helper functions for mongodb | -| cursortoken | Mike | MongoDB cursortoken implementation | -| | | | -| totpext | Mike | Implementation of TOTP (2-Factor-Auth) | -| termext | Mike | Utilities for terminals (mostly color output) | -| confext | Mike | Parses environment configuration into structs | -| cmdext | Mike | Runner for external commands/processes | -| | | | -| sq | Mike | Utility functions for sql based databases | -| tst | Mike | Utility functions for unit tests | -| | | | -| rfctime | Mike | Classes for time seriallization, with different marshallign method for mongo and json | -| gojson | Mike | Same interface for marshalling/unmarshalling as go/json, except with proper serialization of null arrays/maps | -| | | | -| bfcodegen | Mike | Various codegen tools (run via go generate) | -| | | | -| rext | Mike | Regex Wrapper, wraps regexp with a better interface | -| wmo | Mike | Mongo Wrapper, wraps mongodb with a better interface | -| | | | \ No newline at end of file +| Name | Maintainer | Description | +|-------------|------------|---------------------------------------------------------------------------------------------------------------| +| langext | Mike | General uttility/helper functions, (everything thats missing from go standard library) | +| mathext | Mike | Utility/Helper functions for math | +| cryptext | Mike | Utility/Helper functions for encryption | +| syncext | Mike | Utility/Helper funtions for multi-threading / mutex / channels | +| dataext | Mike | Various useful data structures | +| zipext | Mike | Utility for zip/gzip/tar etc | +| reflectext | Mike | Utility for golang reflection | +| fsext | Mike | Utility for filesytem access | +| | | | +| mongoext | Mike | Utility/Helper functions for mongodb | +| cursortoken | Mike | MongoDB cursortoken implementation | +| | | | +| totpext | Mike | Implementation of TOTP (2-Factor-Auth) | +| termext | Mike | Utilities for terminals (mostly color output) | +| confext | Mike | Parses environment configuration into structs | +| cmdext | Mike | Runner for external commands/processes | +| | | | +| sq | Mike | Utility functions for sql based databases | +| tst | Mike | Utility functions for unit tests | +| | | | +| rfctime | Mike | Classes for time seriallization, with different marshallign method for mongo and json | +| gojson | Mike | Same interface for marshalling/unmarshalling as go/json, except with proper serialization of null arrays/maps | +| | | | +| bfcodegen | Mike | Various codegen tools (run via go generate) | +| | | | +| rext | Mike | Regex Wrapper, wraps regexp with a better interface | +| wmo | Mike | Mongo Wrapper, wraps mongodb with a better interface | +| | | | \ No newline at end of file diff --git a/fsext/exists.go b/fsext/exists.go new file mode 100644 index 0000000..3023c72 --- /dev/null +++ b/fsext/exists.go @@ -0,0 +1,36 @@ +package fsext + +import "os" + +func PathExists(fp string) (bool, error) { + _, err := os.Stat(fp) + if err == nil { + return true, nil + } + if os.IsNotExist(err) { + return false, nil + } + return false, err +} + +func FileExists(fp string) (bool, error) { + stat, err := os.Stat(fp) + if err == nil { + return !stat.IsDir(), nil + } + if os.IsNotExist(err) { + return false, nil + } + return false, err +} + +func DirectoryExists(fp string) (bool, error) { + stat, err := os.Stat(fp) + if err == nil { + return stat.IsDir(), nil + } + if os.IsNotExist(err) { + return false, nil + } + return false, err +} diff --git a/go.mod b/go.mod index 2218ebf..9da3df0 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/goccy/go-json v0.10.2 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/compress v1.17.1 // indirect + github.com/klauspost/compress v1.17.2 // indirect github.com/klauspost/cpuid/v2 v2.2.5 // indirect github.com/leodido/go-urn v1.2.4 // indirect github.com/mattn/go-colorable v0.1.13 // indirect diff --git a/go.sum b/go.sum index 264fa02..5aea8f0 100644 --- a/go.sum +++ b/go.sum @@ -49,6 +49,8 @@ github.com/klauspost/compress v1.17.0 h1:Rnbp4K9EjcDuVuHtd0dgA4qNuv9yKDYKK1ulpJw github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/compress v1.17.1 h1:NE3C767s2ak2bweCZo3+rdP4U/HoyVXLv/X9f2gPS5g= github.com/klauspost/compress v1.17.1/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4= +github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= diff --git a/goextVersion.go b/goextVersion.go index b3b5d55..f66ec9f 100644 --- a/goextVersion.go +++ b/goextVersion.go @@ -1,5 +1,5 @@ package goext -const GoextVersion = "0.0.288" +const GoextVersion = "0.0.289" -const GoextVersionTimestamp = "2023-10-19T14:16:01+0200" +const GoextVersionTimestamp = "2023-10-26T11:29:08+0200"