Code Monkey home page Code Monkey logo

Comments (3)

aykevl avatar aykevl commented on August 15, 2024

This is #4156.
This change is a backwards-incompatible change with the goal of being more compatible with existing Go code.

Looking at the code:
https://github.com/tetratelabs/proxy-wasm-go-sdk/blob/v0.23.0/proxywasm/internal/hostcall_utils_tinygo.go#L29

func RawBytePtrToString(raw *byte, size int) string {
	return *(*string)(unsafe.Pointer(&reflect.SliceHeader{
		Data: uintptr(unsafe.Pointer(raw)),
		Len:  uintptr(size),
		Cap:  uintptr(size),
	}))
}

func RawBytePtrToByteSlice(raw *byte, size int) []byte {
	return *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{
		Data: uintptr(unsafe.Pointer(raw)),
		Len:  uintptr(size),
		Cap:  uintptr(size),
	}))
}

The best way to do this nowadays is by using unsafe.String and unsafe.Slice.

(...perhaps this change was a bad idea in hindsight, maybe I should just have said "use unsafe.String and unsafe.Slice" because that's going to work on every compiler).

from tinygo.

acouvreur avatar acouvreur commented on August 15, 2024

Ok, makes sense, thanks.

I'll update the proxy-wasm-go-sdk!

from tinygo.

inliquid avatar inliquid commented on August 15, 2024

Got same issue: knqyf263/go-plugin#64

from tinygo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.