Skip to content

upgrade go version and add more idiomatic Go#61

Open
hilaryRope wants to merge 7 commits into
extism:mainfrom
hilaryRope:more-idiomatic-go
Open

upgrade go version and add more idiomatic Go#61
hilaryRope wants to merge 7 commits into
extism:mainfrom
hilaryRope:more-idiomatic-go

Conversation

@hilaryRope
Copy link
Copy Markdown
Contributor

@hilaryRope hilaryRope commented Apr 5, 2026

Issue: #62

Go PDK Fixes

Version Alignment (Go 1.23)

File Change
go.mod go 1.21.1go 1.23
go.work go 1.21.1go 1.23
wasi-reactor/go.mod go 1.21.1go 1.23

Idiomatic Go 1.22+ Updates

extism_pdk.go

Lines Change
44, 62, 80 Replaced C-style for i := 0; i < n; i++ with for i := range n
297 Replaced make([]byte, 8) + PutUint64 with AppendUint64(nil, ...)

Idiomatic Improvements

extism_pdk.go

Issue Fix
Missing switch case Added LogTrace case to LogLevel.String()
Variable shadowing Renamed memorymem in Send() to avoid shadowing package
Ignored errors Send() now returns (HTTPResponse, error)
Inconsistent receivers HTTPResponse methods now all use pointer receivers
Redundant conversion AllocateBytes([]byte(key)) → AllocateString(key) (6 call sites)
Empty slice literal []byte{}nil in AppendUint32/64 calls
Missing field names Added explicit field names in HTTPResponse struct literal
Missing blank line Added blank line after LogLevel.String()
Redundant variable Removed clength in Output(), use m.Length() directly
Redundant field Removed body: nil in NewHTTPRequest
Redundant nil check Removed in SetHeader, simplified params to key, value string

Typo Fixes

File Issue Fix
example/countvowels/std_main.go Struct name typo CountVowelsOuptutCountVowelsOutput
example/countvowels/tiny_main.go Struct name typo CountVowelsOuptutCountVowelsOutput
example/http/std_main.go Comment typo withuotwithout
extism_pdk.go Doc comment typo unmartialedunmarshaled

Code Cleanup

  • Removed empty default: cases in switch statements (std_main.go, tiny_main.go)

@hilaryRope hilaryRope requested a review from nilslice as a code owner April 5, 2026 23:12
@hilaryRope hilaryRope marked this pull request as draft April 5, 2026 23:12
@hilaryRope hilaryRope marked this pull request as ready for review April 6, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant