gobinaries icon indicating copy to clipboard operation
gobinaries copied to clipboard

Windows support

Open tj opened this issue 4 years ago • 6 comments

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

tj avatar Feb 10 '20 13:02 tj

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

msenturk avatar May 25 '20 21:05 msenturk

@msenturk interesting! thanks :D

tj avatar May 27 '20 09:05 tj

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

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

axetroy avatar Jun 08 '20 17:06 axetroy

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

axetroy avatar Dec 04 '20 14:12 axetroy

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 avatar Apr 22 '21 15:04 mniak

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

mniak avatar Apr 22 '21 16:04 mniak