mirror of
https://github.com/simon-ding/polaris.git
synced 2026-06-06 01:57:40 +08:00
feat: add goreleaser
This commit is contained in:
25
pkg/utils/linux.go
Normal file
25
pkg/utils/linux.go
Normal file
@@ -0,0 +1,25 @@
|
||||
//go:build linux
|
||||
// +build linux
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/unix"
|
||||
"math"
|
||||
"runtime"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func AvailableSpace(dir string) uint64 {
|
||||
if runtime.GOOS != "linux" {
|
||||
return math.MaxUint64
|
||||
}
|
||||
var stat unix.Statfs_t
|
||||
|
||||
unix.Statfs(dir, &stat)
|
||||
return stat.Bavail * uint64(stat.Bsize)
|
||||
}
|
||||
|
||||
func MaxPermission() {
|
||||
syscall.Umask(0) //max permission 0777
|
||||
}
|
||||
16
pkg/utils/other.go
Normal file
16
pkg/utils/other.go
Normal file
@@ -0,0 +1,16 @@
|
||||
//go:build !linux
|
||||
// +build !linux
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"math"
|
||||
)
|
||||
|
||||
func AvailableSpace(dir string) uint64 {
|
||||
return math.MaxUint64
|
||||
}
|
||||
|
||||
func MaxPermission() {
|
||||
return
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"golang.org/x/exp/rand"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func IsASCII(s string) bool {
|
||||
@@ -131,13 +130,6 @@ func SeasonId(seasonName string) (int, error) {
|
||||
return num, nil
|
||||
}
|
||||
|
||||
func AvailableSpace(dir string) uint64 {
|
||||
var stat unix.Statfs_t
|
||||
|
||||
unix.Statfs(dir, &stat)
|
||||
return stat.Bavail * uint64(stat.Bsize)
|
||||
}
|
||||
|
||||
func ChangeFileHash(name string) error {
|
||||
f, err := os.OpenFile(name, os.O_APPEND|os.O_WRONLY, 0655)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user