Skip to content

Instantly share code, notes, and snippets.

View Splizard's full-sized avatar

Quentin Quaadgras Splizard

View GitHub Profile
@Splizard
Splizard / api.go
Created May 27, 2024 09:13
Self-hosted runtime API documentation in Go.
package main
import (
"reflect"
"runtime"
"strings"
"runtime.link/api"
"runtime.link/api/rest"
)
@Splizard
Splizard / Go2GenericType.go
Last active June 10, 2020 16:53
Go 2 generics without syntax changes, 1 new type, 1 new builtin.
//A generics proposal for Go, introducing one new type (generic) and one new builtin function (typeof), no syntax changes.
//Function add takes arguments of any type.
//The return value is automatically inferred based on the arguments, can be inlined by the compiler.
//Both arguments must be the same type and addable or else a compiler error will be raised.
//It's the developer's responsibility to document which types can be passed to this function.
func add(a, b generic) generic {
return a+b
}