Open tj opened 4 years ago
This did the trick on msys64:
curl -sf https://gobinaries.com/rakyll/hey | sh
rename hey to hey.exe
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 interesting! thanks :D
Maybe generating a .ps1
file and processing it by PowerShell can do this
iwr https://gobinaries.com/rakyll/hey?ps1=1 -useb | iex
@tj
Here is an example for Windows installation.
iwr https://deno.land/x/install/install.ps1 -useb | iex
https://deno.land/x/install@v0.1.2/install.ps1
I think it can be used in Golang with a little modification
The user does not need to install other additional tools.
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")
Since this issue seems stall, I created a demo pull request (#40) with my embrionary script (above)
I don't think it works right now, probably need to chuck an
.exe
on there at least.