Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows support #2

Open
tj opened this issue Feb 10, 2020 · 6 comments
Open

Windows support #2

tj opened this issue Feb 10, 2020 · 6 comments
Labels
platform Target platform support

Comments

@tj
Copy link
Owner

tj commented Feb 10, 2020

I don't think it works right now, probably need to chuck an .exe on there at least.

@msenturk
Copy link

This did the trick on msys64:

  • Installed github.com/imachug/win-sudo than copy to it /usr/local/bin
  • curl -sf https://gobinaries.com/rakyll/hey | sh rename hey to hey.exe
  • test it!
C:\Users\hey.exe -n 10 -c 2 -m GET http://example.com

Summary:
  Total:        2.5021 secs
  Slowest:      1.0606 secs
  Fastest:      0.3316 secs
  Average:      0.4985 secs
  Requests/sec: 3.9967
...

@tj
Copy link
Owner Author

tj commented May 27, 2020

@msenturk interesting! thanks :D

@axetroy
Copy link

axetroy commented Jun 8, 2020

Maybe generating a .ps1 file and processing it by PowerShell can do this

iwr https://gobinaries.com/rakyll/hey?ps1=1 -useb | iex

@axetroy
Copy link

axetroy commented Dec 4, 2020

@tj

Here is an example for Windows installation.

iwr https://deno.land/x/install/install.ps1 -useb | iex

https://deno.land/x/[email protected]/install.ps1

I think it can be used in Golang with a little modification

The user does not need to install other additional tools.

@mniak
Copy link

mniak commented Apr 22, 2021

Here is an adaptation I made for powershell taking inspiration in the Deno installation script as in @axetroy comment.
It is not complete (ie. it does not support linux or macos), but for my scenario (windows/amd64) it works.

#!/usr/bin/env pwsh

function Log-Info($message) {
	Write-Output "`e[38;5;61m  ==>`e[0;00m $message"
}
function Log-Critical($message) {
	[Console]::Error.WriteLine("")
	[Console]::Error.WriteLine("  `e[38;5;125m$message`e[0;00m")
	[Console]::Error.WriteLine("")
}
function Get-OS() {
	if ($IsWindows) {
		return "windows"
	} else {
		Log-Critical("Operating system not supported yet")
		Exit 0
	}
	return "unknown"
}
function Get-Architecture() {
	return "$env:PROCESSOR_ARCHITECTURE".ToLower()
}

$OS = Get-OS
$Arch = Get-Architecture

# API endpoint such as "http://localhost:3000"
$API = "https://gobinaries.com"

# package such as "github.com/tj/triage/cmd/triage"
$Pkg = "github.com/rakyll/hey"

# binary name such as "hello"
$Bin ="hey"

# original_version such as "master"
$OriginalVersion="master"

# version such as "master"
$Version="v0.1.4"

$GoBinariesDir = $env:GOBINARIES_DIR
$BinDir = If ($GoBinariesDir) {
  "$GoBinariesDir\bin"
} else {
  "$Home\.gobinaries\bin"
}

$TempExe = "$env:TEMP\$Bin.exe"
$TargetExe = "$BinDir\$Bin.exe"	

If ($OriginalVersion -ne $Version) {
	Log-Info("Resolved version $OriginalVersion to $Version")
}

# GitHub requires TLS 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

Log-Info("Downloading binary for $OS $arch")
$DownloadUrl = "${API}/binary/${Pkg}?os=${OS}&arch=${Arch}&version=${Version}"
Invoke-WebRequest $DownloadUrl -OutFile $TempExe -UseBasicParsing

If (!(Test-Path $BinDir)) {
  New-Item $BinDir -ItemType Directory | Out-Null
}

Copy-Item -Path $TempExe -Destination $TargetExe

If (Test-Path $TempExe) {
	Remove-Item $TempExe
}

$User = [EnvironmentVariableTarget]::User
$Path = [Environment]::GetEnvironmentVariable('Path', $User)
If (!(";$Path;".ToLower() -like "*;$BinDir;*".ToLower())) {
  [Environment]::SetEnvironmentVariable('Path', "$Path;$BinDir", $User)
  $Env:Path += ";$BinDir"
}

Log-Info("Installation complete")

@mniak
Copy link

mniak commented Apr 22, 2021

Since this issue seems stall, I created a demo pull request (#40) with my embrionary script (above)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform Target platform support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants