- Notifications
You must be signed in to change notification settings - Fork18
refactor: use constants for OSs#448
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -36,6 +36,7 @@ import ( | ||
const ( | ||
goosWindows = "windows" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. It's unfortunate that Go doesn't seem to offer these constants in their code anywhere. It looks like Go themselves use hardcoded string comparisons everywhere:https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/golang/go%24+%22windows%22&patternType=literal -- given that, maybe it's okay for us to do that too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Personally I think that doesn't sit well unless at least a type (like TS union of strings as a type alias) is defined. That feels a bit like walking on quicksand. I don't know their reason, but I think it's reasonable we reach for them in our own domain model/application code base. I'd expect there to be some concept of a constant, enumeration or type in other languages when approaching a similar problem. Go sometimes makes odd choices IMO :P | ||
goosLinux = "linux" | ||
goosDarwin = "darwin" | ||
apiPrivateVersion = "/api/private/version" | ||
) | ||
@@ -181,7 +182,7 @@ func (u *updater) Run(ctx context.Context, force bool, coderURLArg string, versi | ||
// TODO: validate the checksum of the downloaded file. GitHub does not currently provide this information | ||
// and we do not generate them yet. | ||
var updatedBinaryName string | ||
if u.osF() ==goosWindows { | ||
updatedBinaryName = "coder.exe" | ||
} else { | ||
updatedBinaryName = "coder" | ||