diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7af6886..b66f75d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,6 +42,7 @@ jobs: path-to-profile: /tmp/coverage/combined.txt flag-name: Go-${{ matrix.go }} parallel: true + if: ${{ github.event.repository.fork == false }} # 仅在非 fork 时上传覆盖率 check-coverage: name: Check coverage @@ -51,14 +52,15 @@ jobs: - uses: shogo82148/actions-goveralls@v1 with: parallel-finished: true + if: ${{ github.event.repository.fork == false }} # 仅在非 fork 时检查覆盖率 # 发布 Release release: name: Release a new version needs: [ lint, test ] runs-on: ubuntu-latest - # 仅在推送标签时执行 - if: ${{ success() && startsWith(github.ref, 'refs/tags/v') }} + # 仅在推送标签时执行 - && - 仅在非 fork 时执行发布 + if: ${{ github.event.repository.fork == false && success() && startsWith(github.ref, 'refs/tags/v') }} steps: # 1. 检出代码 - name: Checkout code diff --git a/go.mod b/go.mod index 247ecaf..f1171ac 100644 --- a/go.mod +++ b/go.mod @@ -6,10 +6,10 @@ require ( github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.10.0 github.com/yyle88/done v1.0.18 - github.com/yyle88/erero v1.0.14 + github.com/yyle88/erero v1.0.15 github.com/yyle88/runpath v1.0.22 - github.com/yyle88/sure v0.0.32 - github.com/yyle88/syntaxgo v0.0.36 + github.com/yyle88/sure v0.0.34 + github.com/yyle88/syntaxgo v0.0.43 github.com/yyle88/zaplog v0.0.16 go.uber.org/zap v1.27.0 ) @@ -20,17 +20,17 @@ require ( github.com/kr/text v0.2.0 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/rogpeppe/go-internal v1.13.1 // indirect - github.com/yyle88/formatgo v1.0.19 // indirect - github.com/yyle88/must v0.0.9 // indirect + github.com/yyle88/formatgo v1.0.21 // indirect + github.com/yyle88/must v0.0.11 // indirect github.com/yyle88/mutexmap v1.0.8 // indirect github.com/yyle88/printgo v1.0.1 // indirect - github.com/yyle88/rese v0.0.1 // indirect - github.com/yyle88/tern v0.0.3 // indirect + github.com/yyle88/rese v0.0.2 // indirect + github.com/yyle88/tern v0.0.4 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect + golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 // indirect golang.org/x/mod v0.22.0 // indirect - golang.org/x/sync v0.9.0 // indirect - golang.org/x/tools v0.27.0 // indirect + golang.org/x/sync v0.10.0 // indirect + golang.org/x/tools v0.28.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index ca73a55..7b10de1 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -17,26 +19,26 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/yyle88/done v1.0.18 h1:O71T+76laNmuY1kYP8PHkp6uceoN6ABTng/8c9KpZts= github.com/yyle88/done v1.0.18/go.mod h1:32UMgjuZP9LctfNNhBQqTyVbjggPOWpoXn8Mp0VrQbw= -github.com/yyle88/erero v1.0.14 h1:ozS3iPLIsnRPSs8AdfbA/3f3hGw5EFkJMkfA/dfI+do= -github.com/yyle88/erero v1.0.14/go.mod h1:NhP5EcPoVlShkMk1cVCFP3im5Zm+JRG35qIInMw7aeo= -github.com/yyle88/formatgo v1.0.19 h1:XgcSB8KsGLTnv7UOCVZDtrd3yJggFd2J82xG5qvmdFI= -github.com/yyle88/formatgo v1.0.19/go.mod h1:Q+JpNGVgskW2Xl+BdHXZ7r6y6TQlQOyN7/23Gu/wzoM= -github.com/yyle88/must v0.0.9 h1:LA03i1O4/6Syopma8xqJMiWfAWeehoySeUaRmdQEvKY= -github.com/yyle88/must v0.0.9/go.mod h1:5Ur4BKRx6GuW4gCZNx8Hf+iRS9lVmywSkCpxun/f+Do= +github.com/yyle88/erero v1.0.15 h1:W3v1eIfX1m2YxYwAAtHky/T0FkreAh87/VZU/xMOFgY= +github.com/yyle88/erero v1.0.15/go.mod h1:NhP5EcPoVlShkMk1cVCFP3im5Zm+JRG35qIInMw7aeo= +github.com/yyle88/formatgo v1.0.21 h1:YPhZf63/f+R1JayJ0Cbnqbc9P/9OJOaYJJpwAhMNdtE= +github.com/yyle88/formatgo v1.0.21/go.mod h1:6lkm0Jk3XfDKIMtcUqc01DcLVXcKaLTYIkWbQbsDCzU= +github.com/yyle88/must v0.0.11 h1:GTDpRMX1wKOkl93C8yQkzKsmrRitmfIdl1cG1siGx38= +github.com/yyle88/must v0.0.11/go.mod h1:5Ur4BKRx6GuW4gCZNx8Hf+iRS9lVmywSkCpxun/f+Do= github.com/yyle88/mutexmap v1.0.8 h1:VntAdXID5wbk211LZEPVK96jQBxIcfVIbQuk9cv3P/8= github.com/yyle88/mutexmap v1.0.8/go.mod h1:QUYDuARLPlGj414kHewQ5tt8jkDxQXoai8H3C4Gg+yc= github.com/yyle88/printgo v1.0.1 h1:0lCpq28Tlf0jmYhSIlDQ7A3hAqVYswhBuURLR9xbmsw= github.com/yyle88/printgo v1.0.1/go.mod h1:yCvpShGBkKdWX5RO+yum2gLbru9ebc04sVmuzhPKSMw= -github.com/yyle88/rese v0.0.1 h1:Eu2I+7BpbkX1n7SOu11AHVqecTuOVdg4becgt2ThGIo= -github.com/yyle88/rese v0.0.1/go.mod h1:GoPiHJPEWyeBL0DxOHT5hLnibFbav+jck/NZxLqNVI8= +github.com/yyle88/rese v0.0.2 h1:UdD5rc2DASd0RAJ322aptWX49keA7j/dvcJmVyreLqg= +github.com/yyle88/rese v0.0.2/go.mod h1:wO23ottjYYp8U+8AFwlTbiHHpxpc9TFYXfjIcN/7szQ= github.com/yyle88/runpath v1.0.22 h1:gcyaNMNZq7yjL2Xlwvs0W7BOkzn4VJTJqA8ko7CKhKg= github.com/yyle88/runpath v1.0.22/go.mod h1:JRGxn/0Ytg6CvGoE2VrO74oX8Lu4jbOPZDKxr8tzPEg= -github.com/yyle88/sure v0.0.32 h1:cUKZDMR2E5c1sc9f99JTZi3GBdBienU3lh3/O98l6/4= -github.com/yyle88/sure v0.0.32/go.mod h1:29eZWpgHwkeK3bq8TL2Db7PP2Zi6JagGJd+gOAjcdjw= -github.com/yyle88/syntaxgo v0.0.36 h1:tBUwonjoqRwP9mjysBC5C1rEIEVEupkwHZzbdHjJgFU= -github.com/yyle88/syntaxgo v0.0.36/go.mod h1:cYNysHxNf58So2Ta4aslUdCvwTnPZj8RqbuNelvD55Q= -github.com/yyle88/tern v0.0.3 h1:Ut5p1wPAVcreEkmzDp+IiteA3K2vnTeAYE1PyBLNgjU= -github.com/yyle88/tern v0.0.3/go.mod h1:g9weyOMLtXYyt37EAshZPUTTHdH7WFauuxDi4oPr7/8= +github.com/yyle88/sure v0.0.34 h1:qKlH0RAvax0m6EcqcSfP8kctBHrkJFa1m7IpY6YqoBU= +github.com/yyle88/sure v0.0.34/go.mod h1:QlR3RWsb+4+hw6it8qb7CTVk8lmhYO9RBWMJl/HWuio= +github.com/yyle88/syntaxgo v0.0.43 h1:G5x7J0br8XvSxytAJJL/DQQ968HSoPBMyNTQ3NpBdII= +github.com/yyle88/syntaxgo v0.0.43/go.mod h1:rmapSvQHkPMsIBYXNa/a4i/31vVGbO0Bt6MOyg00TLs= +github.com/yyle88/tern v0.0.4 h1:PFirncRmdzpMZl6G41Z0Ihmx/XB6PdSQWAHa4a1+PQk= +github.com/yyle88/tern v0.0.4/go.mod h1:g9weyOMLtXYyt37EAshZPUTTHdH7WFauuxDi4oPr7/8= github.com/yyle88/zaplog v0.0.16 h1:ZCxQhq3+nWeWMAXIzeA1EA4exRq5Pn8pXTpEw1GjyD4= github.com/yyle88/zaplog v0.0.16/go.mod h1:0ct8Rh6uE5i9RG+xbH6d4/pyDBt9JmxBqHNCI+T4wiM= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= @@ -45,14 +47,14 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f h1:XdNn9LlyWAhLVp6P/i8QYBW+hlyhrhei9uErw2B5GJo= -golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:D5SMRVC3C2/4+F/DB1wZsLRnSNimn2Sp/NPsCrsv8ak= +golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 h1:1UoZQm6f0P/ZO0w1Ri+f+ifG/gXhegadRdwBIXEFWDo= +golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67/go.mod h1:qj5a5QZpwLU2NLQudwIN5koi3beDhSAlJwa67PuM98c= golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= -golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= -golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o= -golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q= +golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= +golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8= +golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/osexistpath.go b/osexistpath.go index b5b5439..1e1edfd 100644 --- a/osexistpath.go +++ b/osexistpath.go @@ -12,9 +12,9 @@ import ( type CheckMode string const ( - Quiet CheckMode = "QUIET" // Quiet mode, no logs on errors // 比较安静的,即出错时不打印任何日志 Noisy CheckMode = "NOISY" // Noisy mode, logs all errors // 比较吵闹的,即无论什么错误都会打印 Sweet CheckMode = "SWEET" // Sweet mode, logs unexpected errors // 有点适度的,即只打印预料之外的错误 + Quiet CheckMode = "QUIET" // Quiet mode, no logs on errors // 比较安静的,即出错时不打印任何日志 Might CheckMode = "MIGHT" // Might mode, checks type without raising errors // 表示询问的,即询问文件是何种类型的,在调用函数前没有预期,因此不抛出错误 ) @@ -112,6 +112,24 @@ func IsRootExists(path string, verb CheckMode) (bool, error) { return info.IsDir(), nil } +// IsPathExist checks if there is something in the path +// IsPathExist 检查这个路径下是否有东西 +func IsPathExist(path string) (bool, error) { + return IsPathExists(path, Quiet) +} + +// IsFileExist checks if the file exists and returns a boolean +// IsFileExist 检查文件是否存在返回布尔 +func IsFileExist(path string) (bool, error) { + return IsFileExists(path, Quiet) +} + +// IsRootExist checks if the directory exists +// IsRootExist 这个函数就表示目录是否存在,这里使用root表示目录,保持函数名都是4个字母的 +func IsRootExist(path string) (bool, error) { + return IsRootExists(path, Quiet) +} + // IsPath checks if there is something in the path // IsPath 检查这个路径下是否有东西 func IsPath(path string) (bool, error) { diff --git a/osmustexist/osexistpath_must.go b/osmustexist/osexistpath_must.go index 26e2708..8322897 100644 --- a/osmustexist/osexistpath_must.go +++ b/osmustexist/osexistpath_must.go @@ -23,6 +23,24 @@ func IsRootExists(path string, verb osexistpath.CheckMode) bool { return res0 } +func IsPathExist(path string) bool { + res0, err := osexistpath.IsPathExist(path) + sure.Must(err) + return res0 +} + +func IsFileExist(path string) bool { + res0, err := osexistpath.IsFileExist(path) + sure.Must(err) + return res0 +} + +func IsRootExist(path string) bool { + res0, err := osexistpath.IsRootExist(path) + sure.Must(err) + return res0 +} + func IsPath(path string) bool { res0, err := osexistpath.IsPath(path) sure.Must(err) diff --git a/osomitexist/osexistpath_omit.go b/osomitexist/osexistpath_omit.go index e8bc5e8..c410d88 100644 --- a/osomitexist/osexistpath_omit.go +++ b/osomitexist/osexistpath_omit.go @@ -23,6 +23,24 @@ func IsRootExists(path string, verb osexistpath.CheckMode) bool { return res0 } +func IsPathExist(path string) bool { + res0, err := osexistpath.IsPathExist(path) + sure.Omit(err) + return res0 +} + +func IsFileExist(path string) bool { + res0, err := osexistpath.IsFileExist(path) + sure.Omit(err) + return res0 +} + +func IsRootExist(path string) bool { + res0, err := osexistpath.IsRootExist(path) + sure.Omit(err) + return res0 +} + func IsPath(path string) bool { res0, err := osexistpath.IsPath(path) sure.Omit(err) diff --git a/ossoftexist/osexistpath_soft.go b/ossoftexist/osexistpath_soft.go index 8228aae..7763cab 100644 --- a/ossoftexist/osexistpath_soft.go +++ b/ossoftexist/osexistpath_soft.go @@ -23,6 +23,24 @@ func IsRootExists(path string, verb osexistpath.CheckMode) bool { return res0 } +func IsPathExist(path string) bool { + res0, err := osexistpath.IsPathExist(path) + sure.Soft(err) + return res0 +} + +func IsFileExist(path string) bool { + res0, err := osexistpath.IsFileExist(path) + sure.Soft(err) + return res0 +} + +func IsRootExist(path string) bool { + res0, err := osexistpath.IsRootExist(path) + sure.Soft(err) + return res0 +} + func IsPath(path string) bool { res0, err := osexistpath.IsPath(path) sure.Soft(err)