Skip to content

v0.3.0 - interface support, multi-return values, typed envelope return system

Latest

Choose a tag to compare

@RamanSharma100 RamanSharma100 released this 15 Jun 06:17

v0.3.0 Release Notes

go-winplugin v0.3.0

Overview

v0.3.0 is a major feature release delivering full interface support, multi-return value handling, and a completely reworked return value system that eliminates all type ambiguity present in v0.2.0.


What's New

Interface Support

Plugin functions can now accept and work with interface{}, []interface{}, and map[string]any parameters. Values are marshaled to JSON before crossing the DLL boundary and unmarshaled on the plugin side automatically.

func ProcessData(data interface{}) {
    fmt.Println(data)
}
loader.Call("example", "ProcessData", map[string]any{"key": "value"})
loader.Call("example", "ProcessData", []any{1, "two", true})
loader.Call("example", "ProcessData", "hello")
loader.Call("example", "ProcessData", 42)

Multi-Return Values

Functions returning multiple values are now fully supported including error propagation.

func CreateUser(name string, age int) (*User, error) {
    return &User{Name: name, Age: age}, nil
}
result, err := loader.Call("example", "CreateUser", "Jane", 25)
// err is nil, result is map[string]any{"Name": "Jane", "Age": 25}

result, err = loader.Call("example", "CreateUserWithError", "Bad", -1)
// err.Error() == "age cannot be negative"

Typed Envelope Return System

All DLL return values are now wrapped in a typed envelope:

{"type": "scalar", "value": 30}
{"type": "string", "value": "1.0.0"}
{"type": "bool",   "value": true}
{"type": "error",  "value": "something went wrong"}
{"type": "bytes",  "value": "aGVsbG8="}
{"type": "json",   "value": {"Name": "Jane", "Age": 25}}
{"type": "multi",  "value": {"result0": {...}, "error": null}}

This replaces the previous heuristic-based approach (0xFFFF threshold, looksLikeError) with deterministic decoding.

New Supported Return Types

  • []byte
  • error (single return)
  • int64, uint64, float32
  • All struct and *struct types via JSON

Breaking Changes

  • Call return type changed from uintptr to any

Update your call sites from:

result, err := loader.Call("example", "Execute", uintptr(10), uintptr(20))
// result was uintptr
fmt.Println(result) // 30

to:

result, err := loader.Call("example", "Execute", uintptr(10), uintptr(20))
// result is now any (int64 for integer returns)
fmt.Println(result) // 30
if val, ok := result.(int64); ok {
    fmt.Println(val + 1)
}

Bug Fixes

  • Fixed CGO preprocessor crash expected ';', found 'return' in generated wrapper code for multi-return functions — caused by inline IIFEs that exceeded column limits in CGo's C preprocessor
  • Fixed raw pointer values being returned to callers for string/struct/multi returns
  • Fixed multi-return error detection incorrectly requiring error to be the sole key

Installation

go get github.com/RamanSharma100/go-winplugin@v0.3.0

Full Changelog

See [CHANGELOG.md](CHANGELOG.md) for the complete list of changes.