mirror of
https://github.com/syncthing/syncthing.git
synced 2025-12-23 22:18:14 -05:00
all: Add build constants for runtime.GOOS comparisons (#8442)
all: Add package runtimeos for runtime.GOOS comparisons I grew tired of hand written string comparisons. This adds generated constants for the GOOS values, and predefined Is$OS constants that can be iffed on. In a couple of places I rewrote trivial switch:es to if:s, and added Illumos where we checked for Solaris (because they are effectively the same, and if we're going to target one of them that would be Illumos...).
This commit is contained in:
@@ -12,9 +12,10 @@ package integration
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"runtime"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/syncthing/syncthing/lib/build"
|
||||
)
|
||||
|
||||
func printUsage(name string, proc *os.ProcessState, total int64) {
|
||||
@@ -22,7 +23,7 @@ func printUsage(name string, proc *os.ProcessState, total int64) {
|
||||
mib := total / 1024 / 1024
|
||||
log.Printf("%s: Utime: %s / MiB", name, time.Duration(rusage.Utime.Nano()/mib))
|
||||
log.Printf("%s: Stime: %s / MiB", name, time.Duration(rusage.Stime.Nano()/mib))
|
||||
if runtime.GOOS == "darwin" {
|
||||
if build.IsDarwin {
|
||||
// Darwin reports in bytes, Linux seems to report in KiB even
|
||||
// though the manpage says otherwise.
|
||||
rusage.Maxrss /= 1024
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"time"
|
||||
"unicode"
|
||||
|
||||
"github.com/syncthing/syncthing/lib/build"
|
||||
"github.com/syncthing/syncthing/lib/rc"
|
||||
"github.com/syncthing/syncthing/lib/sha256"
|
||||
)
|
||||
@@ -174,7 +175,7 @@ func alterFiles(dir string) error {
|
||||
|
||||
// Change capitalization
|
||||
case r == 2 && comps > 3 && rand.Float64() < 0.2:
|
||||
if runtime.GOOS == "darwin" || runtime.GOOS == "windows" {
|
||||
if build.IsDarwin || build.IsWindows {
|
||||
// Syncthing is currently broken for case-only renames on case-
|
||||
// insensitive platforms.
|
||||
// https://github.com/syncthing/syncthing/issues/1787
|
||||
|
||||
Reference in New Issue
Block a user