Skip to content

Commit 91a9bdf

Browse files
committed
🏗️ Splits PSM1, Removes #Requires from PSM1
Tests were failing because the module was not importable. The `#Requires` syntax being used in the root PSM1 prevented dependencies from being fully resolved before the module loading could complete, making the module unusable.
1 parent f9dda06 commit 91a9bdf

File tree

2 files changed

+169
-163
lines changed

2 files changed

+169
-163
lines changed

src/poshy-wrap-golang.ps1

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
#!/usr/bin/env pwsh
2+
$ErrorActionPreference = "Stop"
3+
Set-StrictMode -Version Latest
4+
#Requires -Modules @{ ModuleName = "poshy-env-var"; RequiredVersion = "0.6.0" }
5+
#Requires -Modules @{ ModuleName = "poshy-lucidity"; RequiredVersion = "0.4.1" }
6+
7+
8+
function Invoke-GoBuild {
9+
go build @args
10+
}
11+
Set-Alias -Name gob -Value Invoke-GoBuild
12+
Export-ModuleMember -Function Invoke-GoBuild -Alias gob
13+
14+
function Invoke-GoClean {
15+
go clean @args
16+
}
17+
Set-Alias -Name goc -Value Invoke-GoClean
18+
Export-ModuleMember -Function Invoke-GoClean -Alias goc
19+
20+
function Invoke-GoDoc {
21+
go doc @args
22+
}
23+
Set-Alias -Name god -Value Invoke-GoDoc
24+
Export-ModuleMember -Function Invoke-GoDoc -Alias god
25+
26+
function Invoke-GoEnv {
27+
go env @args
28+
}
29+
Set-Alias -Name goe -Value Invoke-GoEnv
30+
Export-ModuleMember -Function Invoke-GoEnv -Alias goe
31+
32+
function Invoke-GoFmt {
33+
go fmt @args
34+
}
35+
Set-Alias -Name gof -Value Invoke-GoFmt
36+
Export-ModuleMember -Function Invoke-GoFmt -Alias gof
37+
38+
function Invoke-GoFmtEllipsis {
39+
go go fmt ./... @args
40+
}
41+
Set-Alias -Name gofa -Value Invoke-GoFmtEllipsis
42+
Export-ModuleMember -Function Invoke-GoFmtEllipsis -Alias gofa
43+
44+
function Invoke-GoFix {
45+
go fix @args
46+
}
47+
Set-Alias -Name gofx -Value Invoke-GoFix
48+
Export-ModuleMember -Function Invoke-GoFix -Alias gofx
49+
50+
function Invoke-GoGet {
51+
go get @args
52+
}
53+
Set-Alias -Name gog -Value Invoke-GoGet
54+
Export-ModuleMember -Function Invoke-GoGet -Alias gog
55+
56+
function Invoke-GoGetEllipsis {
57+
go get ./... @args
58+
}
59+
Set-Alias -Name goga -Value Invoke-GoGetEllipsis
60+
Export-ModuleMember -Function Invoke-GoGetEllipsis -Alias goga
61+
62+
function Invoke-GoInstall {
63+
go install @args
64+
}
65+
Set-Alias -Name goi -Value Invoke-GoInstall
66+
Export-ModuleMember -Function Invoke-GoInstall -Alias goi
67+
68+
function Invoke-GoList {
69+
go list @args
70+
}
71+
Set-Alias -Name gol -Value Invoke-GoList
72+
Export-ModuleMember -Function Invoke-GoList -Alias gol
73+
74+
function Invoke-GoMod {
75+
go mod @args
76+
}
77+
Set-Alias -Name gom -Value Invoke-GoMod
78+
Export-ModuleMember -Function Invoke-GoMod -Alias gom
79+
80+
function Set-LocationGoPath {
81+
Get-EnvVarPathItem -Process -Name GOPATH `
82+
| Select-Object -First 1 `
83+
| Set-Location
84+
}
85+
Set-Alias -Name gopa -Value Set-LocationGoPath
86+
Export-ModuleMember -Function Set-LocationGoPath -Alias gopa
87+
88+
function Set-LocationGoPathBin {
89+
Get-EnvVarPathItem -Process -Name GOPATH `
90+
| Select-Object -First 1 `
91+
| ForEach-Object {
92+
Set-Location $_\bin
93+
}
94+
}
95+
Set-Alias -Name gopb -Value Set-LocationGoPathBin
96+
Export-ModuleMember -Function Set-LocationGoPathBin -Alias gopb
97+
98+
function Set-LocationGoPathSrc {
99+
Get-EnvVarPathItem -Process -Name GOPATH `
100+
| Select-Object -First 1 `
101+
| ForEach-Object {
102+
Set-Location $_\src
103+
}
104+
}
105+
Set-Alias -Name gops -Value Set-LocationGoPathSrc
106+
Export-ModuleMember -Function Set-LocationGoPathSrc -Alias gops
107+
108+
function Invoke-GoRun {
109+
go run @args
110+
}
111+
Set-Alias -Name gor -Value Invoke-GoRun
112+
Export-ModuleMember -Function Invoke-GoRun -Alias gor
113+
114+
function Invoke-GoTest {
115+
go test @args
116+
}
117+
Set-Alias -Name got -Value Invoke-GoTest
118+
Export-ModuleMember -Function Invoke-GoTest -Alias got
119+
120+
function Invoke-GoTestEllipsis {
121+
go test ./... @args
122+
}
123+
Set-Alias -Name gota -Value Invoke-GoTestEllipsis
124+
Export-ModuleMember -Function Invoke-GoTestEllipsis -Alias gota
125+
126+
function Invoke-GoTool {
127+
go tool @args
128+
}
129+
Set-Alias -Name goto -Value Invoke-GoTool
130+
Export-ModuleMember -Function Invoke-GoTool -Alias goto
131+
132+
function Invoke-GoToolCompile {
133+
go tool compile @args
134+
}
135+
Set-Alias -Name gotoc -Value Invoke-GoToolCompile
136+
Export-ModuleMember -Function Invoke-GoToolCompile -Alias gotoc
137+
138+
function Invoke-GoToolDist {
139+
go tool dist @args
140+
}
141+
Set-Alias -Name gotod -Value Invoke-GoToolDist
142+
Export-ModuleMember -Function Invoke-GoToolDist -Alias gotod
143+
144+
function Invoke-GoToolFix {
145+
go tool fix @args
146+
}
147+
Set-Alias -Name gotofx -Value Invoke-GoToolFix
148+
Export-ModuleMember -Function Invoke-GoToolFix -Alias gotofx
149+
150+
function Invoke-GoVet {
151+
go vet @args
152+
}
153+
Set-Alias -Name gov -Value Invoke-GoVet
154+
Export-ModuleMember -Function Invoke-GoVet -Alias gov
155+
156+
function Invoke-GoVersion {
157+
go version @args
158+
}
159+
Set-Alias -Name gove -Value Invoke-GoVersion
160+
Export-ModuleMember -Function Invoke-GoVersion -Alias gove
161+
162+
function Invoke-GoWork {
163+
go work @args
164+
}
165+
Set-Alias -Name gow -Value Invoke-GoWork
166+
Export-ModuleMember -Function Invoke-GoWork -Alias gow

src/poshy-wrap-golang.psm1

Lines changed: 3 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -1,170 +1,10 @@
11
#!/usr/bin/env pwsh
22
$ErrorActionPreference = "Stop"
33
Set-StrictMode -Version Latest
4-
#Requires -Modules @{ ModuleName = "poshy-env-var"; RequiredVersion = "0.6.0" }
5-
#Requires -Modules @{ ModuleName = "poshy-lucidity"; RequiredVersion = "0.4.1" }
64

75

8-
if (-not (Test-Command go) -and (-not (Get-Variable -Name PWSHRC_FORCE_MODULES_EXPORT_UNSUPPORTED -Scope Global -ValueOnly -ErrorAction SilentlyContinue))) {
6+
if (-not (Get-Command go -ErrorAction SilentlyContinue) -and (-not (Get-Variable -Name PWSHRC_FORCE_MODULES_EXPORT_UNSUPPORTED -Scope Global -ValueOnly -ErrorAction SilentlyContinue))) {
97
return
8+
} else {
9+
. "$PSScriptRoot/poshy-wrap-golang.ps1"
1010
}
11-
12-
function Invoke-GoBuild {
13-
go build @args
14-
}
15-
Set-Alias -Name gob -Value Invoke-GoBuild
16-
Export-ModuleMember -Function Invoke-GoBuild -Alias gob
17-
18-
function Invoke-GoClean {
19-
go clean @args
20-
}
21-
Set-Alias -Name goc -Value Invoke-GoClean
22-
Export-ModuleMember -Function Invoke-GoClean -Alias goc
23-
24-
function Invoke-GoDoc {
25-
go doc @args
26-
}
27-
Set-Alias -Name god -Value Invoke-GoDoc
28-
Export-ModuleMember -Function Invoke-GoDoc -Alias god
29-
30-
function Invoke-GoEnv {
31-
go env @args
32-
}
33-
Set-Alias -Name goe -Value Invoke-GoEnv
34-
Export-ModuleMember -Function Invoke-GoEnv -Alias goe
35-
36-
function Invoke-GoFmt {
37-
go fmt @args
38-
}
39-
Set-Alias -Name gof -Value Invoke-GoFmt
40-
Export-ModuleMember -Function Invoke-GoFmt -Alias gof
41-
42-
function Invoke-GoFmtEllipsis {
43-
go go fmt ./... @args
44-
}
45-
Set-Alias -Name gofa -Value Invoke-GoFmtEllipsis
46-
Export-ModuleMember -Function Invoke-GoFmtEllipsis -Alias gofa
47-
48-
function Invoke-GoFix {
49-
go fix @args
50-
}
51-
Set-Alias -Name gofx -Value Invoke-GoFix
52-
Export-ModuleMember -Function Invoke-GoFix -Alias gofx
53-
54-
function Invoke-GoGet {
55-
go get @args
56-
}
57-
Set-Alias -Name gog -Value Invoke-GoGet
58-
Export-ModuleMember -Function Invoke-GoGet -Alias gog
59-
60-
function Invoke-GoGetEllipsis {
61-
go get ./... @args
62-
}
63-
Set-Alias -Name goga -Value Invoke-GoGetEllipsis
64-
Export-ModuleMember -Function Invoke-GoGetEllipsis -Alias goga
65-
66-
function Invoke-GoInstall {
67-
go install @args
68-
}
69-
Set-Alias -Name goi -Value Invoke-GoInstall
70-
Export-ModuleMember -Function Invoke-GoInstall -Alias goi
71-
72-
function Invoke-GoList {
73-
go list @args
74-
}
75-
Set-Alias -Name gol -Value Invoke-GoList
76-
Export-ModuleMember -Function Invoke-GoList -Alias gol
77-
78-
function Invoke-GoMod {
79-
go mod @args
80-
}
81-
Set-Alias -Name gom -Value Invoke-GoMod
82-
Export-ModuleMember -Function Invoke-GoMod -Alias gom
83-
84-
function Set-LocationGoPath {
85-
Get-EnvVarPathItem -Process -Name GOPATH `
86-
| Select-Object -First 1 `
87-
| Set-Location
88-
}
89-
Set-Alias -Name gopa -Value Set-LocationGoPath
90-
Export-ModuleMember -Function Set-LocationGoPath -Alias gopa
91-
92-
function Set-LocationGoPathBin {
93-
Get-EnvVarPathItem -Process -Name GOPATH `
94-
| Select-Object -First 1 `
95-
| ForEach-Object {
96-
Set-Location $_\bin
97-
}
98-
}
99-
Set-Alias -Name gopb -Value Set-LocationGoPathBin
100-
Export-ModuleMember -Function Set-LocationGoPathBin -Alias gopb
101-
102-
function Set-LocationGoPathSrc {
103-
Get-EnvVarPathItem -Process -Name GOPATH `
104-
| Select-Object -First 1 `
105-
| ForEach-Object {
106-
Set-Location $_\src
107-
}
108-
}
109-
Set-Alias -Name gops -Value Set-LocationGoPathSrc
110-
Export-ModuleMember -Function Set-LocationGoPathSrc -Alias gops
111-
112-
function Invoke-GoRun {
113-
go run @args
114-
}
115-
Set-Alias -Name gor -Value Invoke-GoRun
116-
Export-ModuleMember -Function Invoke-GoRun -Alias gor
117-
118-
function Invoke-GoTest {
119-
go test @args
120-
}
121-
Set-Alias -Name got -Value Invoke-GoTest
122-
Export-ModuleMember -Function Invoke-GoTest -Alias got
123-
124-
function Invoke-GoTestEllipsis {
125-
go test ./... @args
126-
}
127-
Set-Alias -Name gota -Value Invoke-GoTestEllipsis
128-
Export-ModuleMember -Function Invoke-GoTestEllipsis -Alias gota
129-
130-
function Invoke-GoTool {
131-
go tool @args
132-
}
133-
Set-Alias -Name goto -Value Invoke-GoTool
134-
Export-ModuleMember -Function Invoke-GoTool -Alias goto
135-
136-
function Invoke-GoToolCompile {
137-
go tool compile @args
138-
}
139-
Set-Alias -Name gotoc -Value Invoke-GoToolCompile
140-
Export-ModuleMember -Function Invoke-GoToolCompile -Alias gotoc
141-
142-
function Invoke-GoToolDist {
143-
go tool dist @args
144-
}
145-
Set-Alias -Name gotod -Value Invoke-GoToolDist
146-
Export-ModuleMember -Function Invoke-GoToolDist -Alias gotod
147-
148-
function Invoke-GoToolFix {
149-
go tool fix @args
150-
}
151-
Set-Alias -Name gotofx -Value Invoke-GoToolFix
152-
Export-ModuleMember -Function Invoke-GoToolFix -Alias gotofx
153-
154-
function Invoke-GoVet {
155-
go vet @args
156-
}
157-
Set-Alias -Name gov -Value Invoke-GoVet
158-
Export-ModuleMember -Function Invoke-GoVet -Alias gov
159-
160-
function Invoke-GoVersion {
161-
go version @args
162-
}
163-
Set-Alias -Name gove -Value Invoke-GoVersion
164-
Export-ModuleMember -Function Invoke-GoVersion -Alias gove
165-
166-
function Invoke-GoWork {
167-
go work @args
168-
}
169-
Set-Alias -Name gow -Value Invoke-GoWork
170-
Export-ModuleMember -Function Invoke-GoWork -Alias gow

0 commit comments

Comments
 (0)