macho/macho-go/internal/wrapper/util.go
2023-05-31 16:17:03 +07:00

31 lines
532 B
Go

package wrapper
import (
"fmt"
"os"
log "github.com/sirupsen/logrus"
)
func FileExist(filename string) bool {
info, err := os.Stat(filename)
if os.IsNotExist(err) {
return false
}
return !info.IsDir()
}
func CheckFileExistence(filename string) {
if !FileExist(filename) {
fmt.Printf("File %s does not exists\n", filename)
os.Exit(1)
}
}
func ExperimentalFeature(feature string, foo func()) {
if os.Getenv("EXPERIMENTAL") == "1" {
log.Info(fmt.Sprintf("Running Experimental Feature %s", feature))
foo()
}
}