Skip to content

Commit

Permalink
Adding PowerShell to Minimal Go Installation
Browse files Browse the repository at this point in the history
Separated CMD and PowerShell to add additional support.
  • Loading branch information
shotah authored and aschmahmann committed Jan 14, 2022
1 parent 7e4fcbb commit 562365f
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions docs/windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,36 @@ You can use whichever version of `git` you wish but we recommend the Windows bui

Clone and change directory to the source code, if you haven't already:

```
CMD:
```bat
git clone https://github.com/ipfs/go-ipfs %GOPATH%/src/github.com/ipfs/go-ipfs
cd %GOPATH%/src/github.com/ipfs/go-ipfs/cmd/ipfs
```

PowerShell:
```powershell
git clone https://github.com/ipfs/go-ipfs $env:GOPATH/src/github.com/ipfs/go-ipfs
cd $env:GOPATH/src/github.com/ipfs/go-ipfs/cmd/ipfs
```

We need the `git` commit hash to be included in our build so that in the extremely rare event a bug is found, we have a reference point later for tracking it. We'll ask `git` for it and store it in a variable. The syntax for the next command is different depending on whether you're using the interactive command line or writing a batch file. Use the one that applies to you.
- interactive: `FOR /F %V IN ('git rev-parse --short HEAD') do set SHA=%V`
- interpreter: `FOR /F %%V IN ('git rev-parse --short HEAD') do set SHA=%%V`

Finally, we'll build and test `ipfs` itself.
```

CMD:
```bat
go install -ldflags="-X "github.com/ipfs/go-ipfs".CurrentCommit=%SHA%"
%GOPATH%\bin\ipfs.exe version --all
```

PowerShell:
```powershell
go install -ldflags="-X "github.com/ipfs/go-ipfs".CurrentCommit=$env:SHA"
cp ./ipfs.exe $env:GOPATH/bin/ipfs.exe -force
. $env:GOPATH/bin/ipfs.exe version --all
```
You can check that the ipfs output versions match with `go version` and `git rev-parse --short HEAD`.
If `ipfs.exe` executes and everything matches, then building was successful.

Expand Down

0 comments on commit 562365f

Please sign in to comment.