Skip to content

all: Add build constants for runtime.GOOS comparisons - #8442

Merged
calmh merged 1 commit into
syncthing:mainfrom
calmh:runtimeos
Jul 28, 2022
Merged

calmh merged 1 commit into
syncthing:mainfrom
calmh:runtimeos

Conversation

@calmh

@calmh calmh commented Jul 22, 2022

Copy link
Copy Markdown
Member

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...).

@calmh calmh changed the title all: Add package runtimeos for runtime.GOOS comparisons all: Add build constants for runtime.GOOS comparisons Jul 26, 2022
Comment thread lib/build/runtimeos.go Outdated

package build

//go:generate /bin/sh runtimeos.sh

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not very portable.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it need to be though? This requires regeneration Literally Never(tm) :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this trip whenever someone just runs go generate in the project?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone did, yes, I guess it would. But then they also need to have all the protobuf tools, the mock generator and whatnot installed. I don't think it's a very common thing for anyone to do on a lark. I mean, I could just remove the generator, the generated constants themselves are trivial and could be hand maintained after the initial generation too...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a better option.
Or have a .sh script you can run adhoc to generate.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There, generator is gone; shell script remains for provenance or in case we ever want to update.

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...).
@calmh
calmh enabled auto-merge (squash) July 28, 2022 17:33
@calmh
calmh merged commit a3c724f into syncthing:main Jul 28, 2022
@calmh
calmh deleted the runtimeos branch July 28, 2022 18:33
calmh added a commit to calmh/syncthing that referenced this pull request Jul 28, 2022
* main: (22 commits)
  lib/model: Use bytes.Equal instead of converting to string (syncthing#8469)
  all: Add build constants for runtime.GOOS comparisons (syncthing#8442)
  cmd/strelaysrv: Fix superfluous else statements (syncthing#8468)
  all: Fix nested `if` with `else if` (syncthing#8467)
  all: Unused errors
  lib/fs: Consolidate append in test
  lib/api: Further (final?) unused parameters removal
  cmd/syncthing: Incorrect error handling
  lib/api: String comparisons
  lib/api: Remove unused parameters
  all: Fix unused method receiver (further) (syncthing#8466)
  all: Minor deprecation updates
  lib/model: Clarify normal shallow copy
  lib/api: Missing error handling in config handler (syncthing#8463)
  all: Remove unused method receivers (syncthing#8462)
  all: Combine sequential appends (syncthing#8461)
  cmd/ursrv: Silence linter with correct regexps (syncthing#8460)
  all: Unused parameter should be replaced by underscore (syncthing#8464)
  all: Remove or convert deprecated API usages (syncthing#8459)
  lib/config: Remove unnecessary use of `fmt.Sprintf` (syncthing#8458)
  ...
@calmh calmh added this to the v1.21.0 milestone Aug 9, 2022
calmh added a commit to tomasz1986/syncthing that referenced this pull request Aug 10, 2022
* main: (94 commits)
  build: bump actions/setup-go from 2.2.0 to 3.2.1 (syncthing#8492)
  build: Let dependabot suggest updates to GitHub actions (syncthing#8490)
  update: Go version in update-docs-translations action (syncthing#8489)
  gui, man, authors: Update docs, translations, and contributors
  cmd/syncthing: Refactor CLI code to allow passing CLI arguments via function parameter (syncthing#8485)
  build: Update quic-go for Go 1.19 (syncthing#8483)
  lib/ur: Properly initialize map in failure data (fixes syncthing#8479) (syncthing#8480)
  lib/ur: Properly initialize map in failure data (fixes syncthing#8479)
  gui, man, authors: Update docs, translations, and contributors
  docs: Clarify docker network mode limitations (syncthing#8472)
  lib/config: Use net.JoinHostPort instead of string manipulation (syncthing#8470)
  lib/api: Fix inverted logic in string comparison
  lib/model: Use bytes.Equal instead of converting to string (syncthing#8469)
  all: Add build constants for runtime.GOOS comparisons (syncthing#8442)
  cmd/strelaysrv: Fix superfluous else statements (syncthing#8468)
  all: Fix nested `if` with `else if` (syncthing#8467)
  all: Unused errors
  lib/fs: Consolidate append in test
  lib/api: Further (final?) unused parameters removal
  cmd/syncthing: Incorrect error handling
  ...
calmh added a commit to acolomb/syncthing that referenced this pull request Aug 10, 2022
* main: (121 commits)
  gui, api: Show internal config and state paths (fixes syncthing#8323) (syncthing#8324)
  build(deps): bump github.com/go-ldap/ldap/v3 from 3.4.1 to 3.4.4 (syncthing#8475)
  build: bump actions/setup-go from 2.2.0 to 3.2.1 (syncthing#8492)
  build: Let dependabot suggest updates to GitHub actions (syncthing#8490)
  update: Go version in update-docs-translations action (syncthing#8489)
  gui, man, authors: Update docs, translations, and contributors
  cmd/syncthing: Refactor CLI code to allow passing CLI arguments via function parameter (syncthing#8485)
  build: Update quic-go for Go 1.19 (syncthing#8483)
  lib/ur: Properly initialize map in failure data (fixes syncthing#8479) (syncthing#8480)
  lib/ur: Properly initialize map in failure data (fixes syncthing#8479)
  gui, man, authors: Update docs, translations, and contributors
  docs: Clarify docker network mode limitations (syncthing#8472)
  lib/config: Use net.JoinHostPort instead of string manipulation (syncthing#8470)
  lib/api: Fix inverted logic in string comparison
  lib/model: Use bytes.Equal instead of converting to string (syncthing#8469)
  all: Add build constants for runtime.GOOS comparisons (syncthing#8442)
  cmd/strelaysrv: Fix superfluous else statements (syncthing#8468)
  all: Fix nested `if` with `else if` (syncthing#8467)
  all: Unused errors
  lib/fs: Consolidate append in test
  ...
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Jul 28, 2023
@syncthing syncthing locked and limited conversation to collaborators Jul 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants