Skip to content

How to expose a function with arguments for WebAssembly wasm generation?  #41715

Closed
@thstart

Description

@thstart

What version of Go are you using (go version)?

$ go version
go1.15.2

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOOS="darw"

What did you do?

package main

import "C"

//export Sum
func Sum(a, b int) int {
return a + b
}

func main() {
// We need the main function to make possible
// CGO compiler to compile the package as C shared library
}

What did you expect to see?

I want to expose the Sum function which accepts arguments in order to use it
in a non browser environment.

Currently there is no way to do that mucous only main() is exposed.

What did you see instead?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions