iqlink

module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: 0BSD

README

Background:

This project was originally published as open source by IQ Hive under the runtime.link import path. Following a maintainer’s departure from IQ Hive, the vanity domain was redirected to that maintainer’s separate repository without prior notice to IQ Hive. Development has continued independently in both repositories. IQ Hive’s version now uses direct GitHub import paths so applications can reliably depend on the implementation maintained here as it contains features that other open source IQ Hive project depend on.

In order to avoid confusion between the 2 similar-named but divergent feature-sets, this project was renamed iqlink.

iqlink will continue to automatically import features from the runtime.link implementation for a period of time, or until such time as the features conflict in a way that prevents this happening.

Summary

One Go API specification can support several ways of calling the same software. Define the interface in Go source, then use iqlink's runtime linkers to connect it to an implementation.

iqlink provides a dictionary for expressing software interfaces in Go source. Its Go linkers connect those interface definitions to implementations at runtime through network protocols such as HTTP, command line interfaces, or native application binary interfaces (ABIs) on supported platforms.

  • Describe operations with typed structures, function fields and tags that record how each operation is exposed.
  • Call or serve HTTP APIs, run command line programs, and connect to native libraries through supported ABIs.
  • Inspect calls with xray and create empty implementations with stub for development and debugging.

iqlink is still in development. We aim to keep established components stable, but minor breaking changes remain possible before the first stable release.

Example:

// Package example provides the specification for the iqlink example API.
package example

import (
	"log"
	"os"

	"github.com/iqhive/iqlink/api"
)

// API specification structure, typically named API for general structures, may
// be more suitably named Functions, Library or Command when the API is
// restricted to a specific iqlink layer. Any Go comments in the source
// are intended to document design notes and ideas. This leaves Go struct tags
// for recording developer-facing documentation.
type API struct {
	api.Specification `api:"Example" cmd:"example" lib:"libexample"
		is an example of an iqlink API structure.` // this section of the tag contains documentation.

	// HelloWorld includes iqlink tags that specify how the function is called
	// across different link-layers. Typically, a context.Context argument and error
	// return value should be included here, they are omitted here for brevity.
	HelloWorld func() string `cmdl:"hello_world" link:"example_helloworld func()$char" rest:"GET /hello_world"
		returns the string "Hello World"` // documentation for the function.
}

// New returns an implementation of the API. This doesn't have to be defined in the
// same package and may not even be implemented in Go. This will often be the case when
// representing an external API controlled by a third-party.
func New() API {
	return API{
		HelloWorld: func() string {
			return "Hello World"
		},
	}
}

More Practical Examples

Run any of them with go run, for example go run ./examples/advanced; each directory's tests check the output shown in its comments.

Runtime Linkers.

Each linker lives under the api package and enables an API to be linked against a host implementation via a standard communication protocol. A linker can also serve a host implementation written in Go.

Currently available iqlink linkers include:

* cmdl - parse command line arguments or execute command line programs.
* link - generate c-shared export directives or dynamicaly link to shared libraries (via ABI).
* rest - link to, or host a REST API server over the network.
* stub - create a stub implementation of an API, that returns empty values or errors.
* xray - debug linkers with API call introspection.

Parameter names

API structures can opt in to exposing the Go parameter and result names written in their func fields, so linkers can use them as defaults (REST body/result mapping, cmdl help text, wasm debug names). Explicit struct tags always win; names are never required.

//go:embed *.go
var source embed.FS

func (API) Source() fs.FS { return source }

Alternatively, api.RegisterSource[API](files) associates source with every struct type in that package. The source is parsed once per package; failure to obtain names is silent. Embedding .go files increases binary size and ships the spec source in the binary — for single-file specs prefer //go:embed api.go.

Our Design Values

  1. Full readable words for exported identifiers rather than abbreviations ie. PutString over puts.
  2. Acronyms as package names and/or as a suffix, rather than mixed use ie. TheExampleAPI over TheAPIExample.
  3. Explicitly tagged types that define data relationships rather than implicit use of primitives. Customer CustomerID over Customer string.
  4. Don't stutter exported identifiers. customer.Account over customer.Customer.

Contribution Guidance

Apart from what's on the Roadmap, we cannot accept any pull requests for new top level packages at this time, although you are welcome to start a GitHub Discussion for any ideas you may have, our current goal for iqlink is to stick to a well-defined and cohesive design space.

iqlink aims to be dependency free, we will not accept any pull requests that add any additional Go dependencies to the project.

NOTE: we adopt a different convention for Go struct tags, which are permitted to be multi-line and include inline-documentation on subsequent lines of the tag. This can raise a warning with Go linters, so we recommend using the following configurations:

govet go vet -structtag=false ./...

VS Code + gopls

"go.vetFlags": [
    "-structtag=false"
],
"gopls": {
    "analyses": {
        "structtag": false
    },
},

Zed:

"lsp": {
  "gopls": {
    "initialization_options": {
      "analyses": {
        "structtag": false
      }
    }
  }
}

golangci-lint.yml

linters-settings:
  govet:
    disable:
      - structtag # support iqlink convention.

Roadmap

  • Support for additional linkers, such as mock, grpc, soap, jrpc, xrpc, and sock.

Directories

Path Synopsis
api
Package api defines the standard runtime reflection representation for an iqlink API structure.
Package api defines the standard runtime reflection representation for an iqlink API structure.
call
Package call provides shared library linker for iqlink (WORK-IN-PROGRESS).
Package call provides shared library linker for iqlink (WORK-IN-PROGRESS).
call/internal/abi
Package abi provides an interface to the platform-standard ABI calling conventions and type system (typically C).
Package abi provides an interface to the platform-standard ABI calling conventions and type system (typically C).
call/internal/bin
Package bin enables you to represent binary formats.
Package bin enables you to represent binary formats.
call/internal/bin/std/cpu/amd64
Package amd64 provides an instruction set specification for the AMD64 architecture.
Package amd64 provides an instruction set specification for the AMD64 architecture.
call/internal/bin/std/cpu/arm64
Package arm64 provides an instruction set specification for the ARM64 architecture.
Package arm64 provides an instruction set specification for the ARM64 architecture.
call/internal/dll
Package dll provides methods for dynamically loading shared libraries and symbol lookup.
Package dll provides methods for dynamically loading shared libraries and symbol lookup.
call/internal/ffi
Package ffi provides information about the platform-native C ABI types.
Package ffi provides information about the platform-native C ABI types.
call/internal/jit
Package jit provides a safe alternative to reflect.MakeFunc with support for transparent optimisation.
Package jit provides a safe alternative to reflect.MakeFunc with support for transparent optimisation.
cmdl
Package cmdl provides a command-line interface linker for iqlink.
Package cmdl provides a command-line interface linker for iqlink.
data
Package data provides ways to declare validation constraints on values, these constraints can be reflected upon at runtime.
Package data provides ways to declare validation constraints on values, these constraints can be reflected upon at runtime.
example command
example/petstore
Package petstore serves as an example for how to represent a REST API specification.
Package petstore serves as an example for how to represent a REST API specification.
fmts
Package fmts provides a format specification API linker.
Package fmts provides a format specification API linker.
grpc
Package grpc implements Protocol Buffer codecs.
Package grpc implements Protocol Buffer codecs.
internal/http
Package http provides an extendable shell API based on http.
Package http provides an extendable shell API based on http.
internal/oas
Package oas provides a representation of the OpenAPI Specification (OAS) Version 3.2.0
Package oas provides a representation of the OpenAPI Specification (OAS) Version 3.2.0
internal/rtags
Package rtags provides methods for reading a rest.Tag, do not make this public, instead extend the rest.Tag with methods if required.
Package rtags provides methods for reading a rest.Tag, do not make this public, instead extend the rest.Tag with methods if required.
jrpc
Package jrpc implements JSON-RPC codecs.
Package jrpc implements JSON-RPC codecs.
open/gl
Code generated by generate.go; DO NOT EDIT.
Code generated by generate.go; DO NOT EDIT.
rest
Package rest provides a REST API transport.
Package rest provides a REST API transport.
stub
Package stub provides a stub api.Linker that returns empty values and specific errors.
Package stub provides a stub api.Linker that returns empty values and specific errors.
test
Package test provides the data structures for testrun execution and analysis.
Package test provides the data structures for testrun execution and analysis.
xray
Package xray provides standard means for introspecting the internal operational state of an [api.Linker].
Package xray provides standard means for introspecting the internal operational state of an [api.Linker].
examples
advanced command
Command advanced serves the bookshop API on a local port and calls it as three different clients, printing each HTTP exchange.
Command advanced serves the bookshop API on a local port and calls it as three different clients, printing each HTTP exchange.
advanced/bookshop
Package bookshop specifies a small online bookshop.
Package bookshop specifies a small online bookshop.
http/client command
Command client calls the notes API served by examples/http/server.
Command client calls the notes API served by examples/http/server.
http/notes
Package notes is the API specification shared by the notes server and client.
Package notes is the API specification shared by the notes server and client.
http/server command
Command server serves the notes API over HTTP.
Command server serves the notes API over HTTP.
simple command
Command simple is the smallest useful iqlink program: an API specification, a Go implementation of it, and the cmdl linker turning it into a command line.
Command simple is the smallest useful iqlink program: an API specification, a Go implementation of it, and the cmdl linker turning it into a command line.
key
cuid
Package cuid provides production-ready CUID identifier types.
Package cuid provides production-ready CUID identifier types.
internal/id
Package id contains small, private helpers shared by the identifier packages under github.com/iqhive/iqlink/key (uuid, ulid, ksuid, cuid, nanoid, snow).
Package id contains small, private helpers shared by the identifier packages under github.com/iqhive/iqlink/key (uuid, ulid, ksuid, cuid, nanoid, snow).
ksuid
Package ksuid provides a production-ready KSUID (K-Sortable Unique IDentifier) type.
Package ksuid provides a production-ready KSUID (K-Sortable Unique IDentifier) type.
nanoid
Package nanoid provides a production-ready Nano ID identifier type.
Package nanoid provides a production-ready Nano ID identifier type.
snow
Package snow provides a production-ready Snowflake ID type.
Package snow provides a production-ready Snowflake ID type.
ulid
Package ulid provides a production-ready ULID (Universally Unique Lexicographically Sortable Identifier) type.
Package ulid provides a production-ready ULID (Universally Unique Lexicographically Sortable Identifier) type.
uuid
Package uuid provides production-ready RFC 9562 UUID identifier types.
Package uuid provides production-ready RFC 9562 UUID identifier types.
uuid/internal/stduuid
Package stduuid is an internal compatibility layer that exposes a stable, minimal UUID API to the github.com/iqhive/iqlink/key/uuid package regardless of the Go toolchain version used to build it.
Package stduuid is an internal compatibility layer that exposes a stable, minimal UUID API to the github.com/iqhive/iqlink/key/uuid package regardless of the Go toolchain version used to build it.
pii
Package qnq provides a representation for message queuing, event handling and callback flows.
Package qnq provides a representation for message queuing, event handling and callback flows.
sql
Package sql defines a data map type with support for type-safe structured queries.
Package sql defines a data map type with support for type-safe structured queries.
std/sodium
Package sodium provides a specification for the SODIUM standard database interface.
Package sodium provides a specification for the SODIUM standard database interface.
xyz
Package xyz provides switch types, tuples and a binary sequence tag.
Package xyz provides switch types, tuples and a binary sequence tag.

Jump to

Keyboard shortcuts

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