directfunc

package
v1.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 1 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Direct funcs

Register a signature by embedding DirectFuncVal and binding a method. This example makes interpreted func(int) int values ordinary Go functions:

package myint

import "github.com/goplus/ixgo"

type fn struct{ ixgo.DirectFuncVal }

func (c fn) Int(n int) int {
	return c.Call(n).(int)
}

func init() {
	ixgo.RegisterDirectFuncFor(func(c ixgo.DirectFuncVal) func(int) int {
		return fn{c}.Int
	})
}
src := `package main
func main() {
	add := func(x int) int { return x + 1 }
	println(add(41))
}
`
ixgo.RunFile("main.go", src, nil, 0)

func() is built into ixgo. Import this package for common func() T results.

import _ "github.com/goplus/ixgo/directfunc"

Registered signatures:

  • func() bool
  • func() int / int8 / int16 / int32 / int64
  • func() uint / uint8 / uint16 / uint32 / uint64 / uintptr
  • func() float32 / float64
  • func() string
  • func() error

Named types (for example type Action func()) stay on reflect.MakeFunc unless the host registers them.

A later registration for the same signature replaces an earlier one. Passing a nil maker to RegisterDirectFunc, or a nil bind to RegisterDirectFuncFor, removes the registration. Do not unregister or replace a signature while function values of that type are still in use.

Documentation

Overview

Package directfunc registers DirectFunc wrappers for func() T with common result types.

import _ "github.com/goplus/ixgo/directfunc"

func() is built into ixgo. Signatures with parameters are not registered here. Register those from the host with ixgo.RegisterDirectFuncFor.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL