util

package module
v0.0.0-...-ae64dec Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2025 License: GPL-3.0 Imports: 60 Imported by: 30

README ΒΆ

util

A collection of useful types/functions for Go developers.

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

View Source
var Digits = "0123456789"
View Source
var Letters = "abcdefghijklmnopqrstuvwxyz"

Functions ΒΆ

func Accept ΒΆ

func Accept(r *http.Request, format string) bool

func AddToKnownHosts ΒΆ

func AddToKnownHosts(user, server string) error

func AppendUsingReflect ΒΆ

func AppendUsingReflect(slice any, value any) any

func AuthenticateTailscale ΒΆ

func AuthenticateTailscale(authkey string) error

func BackupDir ΒΆ

func BackupDir(path string, encKey string, outfile string) error

func Bit ΒΆ

func Bit(b byte, i int) bool

Bit returns the bit value of the bit at index i of b. It panics if i is out of range (1-8).

func CallMethod ΒΆ

func CallMethod(v any, m string, args []string) ([]string, error)

CallMethod takes any value, a method name, and an array of JSON-encoded strings. It parses these strings into method arguments and invokes the method, including support for variadic functions. Returns the result of the method call or an error.

func ClientIP ΒΆ

func ClientIP(r *http.Request) string

func CmdlineServer ΒΆ

func CmdlineServer(h http.Handler)

CmdlineServer let's you easily turn any http.Handler into a cmdline app.

func CompressDir ΒΆ

func CompressDir(dir, outFile string) error

CompressDir compresses the specified directory into a .tar.gz file.

func ContentType ΒΆ

func ContentType(r *http.Request, format string) bool
func Cookie(r *http.Request, id string) string

func CopyDir ΒΆ

func CopyDir(srcDir, dstDir string) error

CopyDir recursively copies a directory from src to dst.

func CopyFile ΒΆ

func CopyFile(src, dst string) error

CopyFile copies a file from src to dst. If dst does not exist, it will be created.

func CopyFileFromRemote ΒΆ

func CopyFileFromRemote(user, addr, src, dst string) ([]byte, error)

func CopyFileToRemote ΒΆ

func CopyFileToRemote(user, addr, src, dst string) ([]byte, error)

func CreateFile ΒΆ

func CreateFile(path string) (*os.File, error)

func CreateP ΒΆ

func CreateP(name string) (*os.File, error)

func DecryptAndDecompressDir ΒΆ

func DecryptAndDecompressDir(src io.Reader, dst string, key string) error

func DeleteCookie ΒΆ

func DeleteCookie(w http.ResponseWriter, name string)

func Download ΒΆ

func Download(url, target string) error

func DownloadDir ΒΆ

func DownloadDir(user, host, path string) ([]byte, error)

func Drill ΒΆ

func Drill(v any, path []string) (any, error)

func EncryptAndCompressDir ΒΆ

func EncryptAndCompressDir(src string, buf io.Writer, key string) error

func EncryptedReader ΒΆ

func EncryptedReader(key string, r io.Reader) (*cipher.StreamReader, error)

EncryptedReader wraps r with an OFB cipher stream.

func EncryptedWriter ΒΆ

func EncryptedWriter(key string, w io.Writer) (*cipher.StreamWriter, error)

EncryptedWriter wraps w with an OFB cipher stream.

func EnvVar ΒΆ

func EnvVar(name string, def string) string

func ErrorHTTP ΒΆ

func ErrorHTTP(w http.ResponseWriter, code int)

func ExecRemote ΒΆ

func ExecRemote(user, host, cmd string) ([]byte, error)

func Exists ΒΆ

func Exists(path string) bool

func FReadJSONFile ΒΆ

func FReadJSONFile(fsys fs.FS, path string, v any) error

func FieldValue ΒΆ

func FieldValue(v any, f string) any

func FilterString ΒΆ

func FilterString(input, charset string) string

func FilterTestFiles ΒΆ

func FilterTestFiles(fi fs.FileInfo) bool

func Flatten ΒΆ

func Flatten(v any) map[string]string

Flatten any Go object into a map[string]string. Paths are '/'-separated.

func FprintJSON ΒΆ

func FprintJSON(w io.Writer, v any) (int, error)

func FrequencyToRGB ΒΆ

func FrequencyToRGB(frequency float64) string

FrequencyToRGB converts a light frequency in THz to an RGB hex string.

func GetAddr ΒΆ

func GetAddr() string

func GetInstalledGoVersion ΒΆ

func GetInstalledGoVersion() (string, error)

func GetLatestGoVersion ΒΆ

func GetLatestGoVersion() (string, error)

func GetName ΒΆ

func GetName(v any) string

func GetOSID ΒΆ

func GetOSID() (string, error)

func GetPasswordFromStdin ΒΆ

func GetPasswordFromStdin(prompt string) (string, error)

func HandleCORS ΒΆ

func HandleCORS(w http.ResponseWriter, r *http.Request)

func HandlePUT ΒΆ

func HandlePUT(w http.ResponseWriter, r *http.Request, v any)

func HasMethod ΒΆ

func HasMethod(v any, m string) bool

func HomeDir ΒΆ

func HomeDir() string

func InstallGo ΒΆ

func InstallGo() error

func InstallNode ΒΆ

func InstallNode() error

func InstallTailscale ΒΆ

func InstallTailscale() error

func IntToID ΒΆ

func IntToID(v int64) string

func IsAlphaNumeric ΒΆ

func IsAlphaNumeric(ch rune) bool

func IsArray ΒΆ

func IsArray(v any) bool

func IsBool ΒΆ

func IsBool(v any) bool

func IsDir ΒΆ

func IsDir(path string) bool

func IsInt ΒΆ

func IsInt(v any) bool

func IsLoopbackIP ΒΆ

func IsLoopbackIP(ip net.IP) bool

func IsMap ΒΆ

func IsMap(v any) bool

func IsMutation ΒΆ

func IsMutation(r *http.Request) bool

func IsPrivateIP ΒΆ

func IsPrivateIP(ip net.IP) bool

func IsPublicIP ΒΆ

func IsPublicIP(ip net.IP) bool

func IsRootRequest ΒΆ

func IsRootRequest(r *http.Request) bool

func IsStdlib ΒΆ

func IsStdlib(pkg string) bool

func IsString ΒΆ

func IsString(v any) bool

func IsStruct ΒΆ

func IsStruct(v any) bool

func IsTenDigits ΒΆ

func IsTenDigits(phone string) bool

func JSONString ΒΆ

func JSONString(v any) string

func JoinPath ΒΆ

func JoinPath(path []string) string

func KebabCase ΒΆ

func KebabCase(s string) string

func Kind ΒΆ

func Kind(v interface{}) string

Kind determines the kind of a given value. It returns one of "struct", "map", "list", "scalar" or "null".

func LatestGoVersion ΒΆ

func LatestGoVersion() string

func ListenAndServe ΒΆ

func ListenAndServe(h http.Handler) error

func MIMEType ΒΆ

func MIMEType(file string) string

func Main ΒΆ

func Main(s http.Handler)

func Must ΒΆ

func Must[T any](v T, err error) T

func NewRecursiveWatcher ΒΆ

func NewRecursiveWatcher(dir string) (*fsnotify.Watcher, error)

func NewReverseProxy ΒΆ

func NewReverseProxy(backendURL string) *httputil.ReverseProxy

func NewServeMux ΒΆ

func NewServeMux(handlers map[string]http.Handler) http.Handler

func NormalizeGoName ΒΆ

func NormalizeGoName(s string) string

func NormalizePhoneNumber ΒΆ

func NormalizePhoneNumber(number string) string

func OS ΒΆ

func OS() string

func OnFileChange ΒΆ

func OnFileChange(path string, callback func()) error

OnFileChange sets up a watcher that calls `callback()` ONCE each time the file's contents change.

func OnlyLowerCase ΒΆ

func OnlyLowerCase(s string) string

func OnlyOne ΒΆ

func OnlyOne[T any](m map[string]T) (id string, value T, ok bool)

func OptionallyServeHTTP ΒΆ

func OptionallyServeHTTP(v any, w http.ResponseWriter, r *http.Request)

func PackageManager ΒΆ

func PackageManager() string

func ParseJSON ΒΆ

func ParseJSON[T any](s string) T

func ParsePath ΒΆ

func ParsePath(s string) []string

func PascalCase ΒΆ

func PascalCase(s string) string

func PasswordProtected ΒΆ

func PasswordProtected(passwd string, h http.Handler) http.Handler

func Pop ΒΆ

func Pop[T any](items []T) (T, []T)

func PopPath ΒΆ

func PopPath(path string) (first string, rest string, isRoot bool)

func Port ΒΆ

func Port() string

func PrintJSON ΒΆ

func PrintJSON(v any) (int, error)

func PrintResponse ΒΆ

func PrintResponse(resp *http.Response)

func QuadrupleTime ΒΆ

func QuadrupleTime(fn1, fn2, fn3, fn4 func()) error

Run each fn 250 ms apart forever. Returns an error if a func takes longer than 249 ms to run.

func RandomBits ΒΆ

func RandomBits(n int) []bool

func RandomBytes ΒΆ

func RandomBytes(n int) []byte

func RandomCode ΒΆ

func RandomCode(digits int) string

func RandomDigit ΒΆ

func RandomDigit() int

func RandomElement ΒΆ

func RandomElement[T any](arr []T) (T, error)

func RandomID ΒΆ

func RandomID() string

RandomID returns a 32-byte hex encoded string. The first 8 bytes are a nano-second precision UNIX time-stamp. The next 24 bytes are generated by /dev/urandom.

func RandomString ΒΆ

func RandomString(length int, charset string) string

func RandomToken ΒΆ

func RandomToken(bytes int) string

func ReadDir ΒΆ

func ReadDir(path string) ([]string, error)

func ReadGoPackageFromDisk ΒΆ

func ReadGoPackageFromDisk(dir string) (*ast.Package, error)

func ReadJSON ΒΆ

func ReadJSON[T any](r io.Reader) *T

func ReadJSONFS ΒΆ

func ReadJSONFS(w io.Writer, t *Type, path string) error

func ReadJSONFile ΒΆ

func ReadJSONFile(path string, v any) error

func ReadRemoteFile ΒΆ

func ReadRemoteFile(user, password, host string, port int, remotePath string) (string, error)

func ReloadSystemd ΒΆ

func ReloadSystemd() error

func RenderTemplateToFile ΒΆ

func RenderTemplateToFile(tmpl string, path string, in any) error

func RequireEnvVar ΒΆ

func RequireEnvVar(name string) string

func RestoreDir ΒΆ

func RestoreDir(backupFile string, encKey string, outDir string) error

func Run ΒΆ

func Run(cmd *exec.Cmd) error

func RunInParallel ΒΆ

func RunInParallel(fns []func() error) []error

RunInParallel runs each function in fns in its own goroutine, waits for all to finish, and returns a slice of errors (same order, same length).

func RunSSHCommandWithKnownHostsCheck ΒΆ

func RunSSHCommandWithKnownHostsCheck(host, user, cmd string, auth []ssh.AuthMethod) ([]byte, error)

func SHA256 ΒΆ

func SHA256(b []byte) []byte

func SSHClientConfig ΒΆ

func SSHClientConfig(user string) (*ssh.ClientConfig, error)

func SecurePassword ΒΆ

func SecurePassword() string

func Serialize ΒΆ

func Serialize(v any) []byte

func Serve ΒΆ

func Serve(s http.Handler)

func ServeAll ΒΆ

func ServeAll(handlers map[string]http.Handler) error

func ServeAny ΒΆ

func ServeAny(v any, w http.ResponseWriter, r *http.Request)

ServeAny serves any Go value. Drill into any exported struct field or map/arary value. Arrays start at 1001. GET requests are served the JSON encoded values. POST requests are used to call methods. Ex request body: `{"Method":"Add","Args":["1","2","3"]}`. All args are JSON-encoded strings. The server will unmarshal each arg into it's appropriate type. Ex response body: `["6","null"]`.

func ServeBool ΒΆ

func ServeBool(path []string, v any, w http.ResponseWriter, r *http.Request)

func ServeError οΏ½οΏ½

func ServeError(w http.ResponseWriter, code int)

func ServeHTTPS ΒΆ

func ServeHTTPS(h http.Handler, email, certDir string, allowHost func(host string) bool) error

ServeHTTPS serves h on HTTP and HTTPS ports handling tls.

func ServeMethod ΒΆ

func ServeMethod(m string, v any, w http.ResponseWriter, r *http.Request)

func ServeMyIP ΒΆ

func ServeMyIP(w http.ResponseWriter, r *http.Request)

func ServeObject ΒΆ

func ServeObject(path []string, v Object, w http.ResponseWriter, r *http.Request)

func SetField ΒΆ

func SetField(v any, fieldName string, fieldValue any)

func SnakeCase ΒΆ

func SnakeCase(s string) string

func SortedKeys ΒΆ

func SortedKeys[T any](m map[string]T) []string

func StartServer ΒΆ

func StartServer(s http.Handler) error

func StripNonAlphaNumeric ΒΆ

func StripNonAlphaNumeric(s string) string

func StructToMap ΒΆ

func StructToMap(val any) map[string]any

func SubFS ΒΆ

func SubFS(fsys fs.FS, dir string) fs.FS

func Sync ΒΆ

func Sync(src, dst string) error

func TitleCase ΒΆ

func TitleCase(s string) string

func Touch ΒΆ

func Touch(path string) error

func UnixNanoTimestamp ΒΆ

func UnixNanoTimestamp() string

func UnixTimestamp ΒΆ

func UnixTimestamp() string

func UploadDir ΒΆ

func UploadDir(user, host string, b []byte, path string) error

func UserPassServer ΒΆ

func UserPassServer(user string, pass string, h http.Handler) http.Handler

func WaitUntil ΒΆ

func WaitUntil(h, m, s int)

func Watch ΒΆ

func Watch(path string, fn func()) error

func WavelengthToRGB ΒΆ

func WavelengthToRGB(wavelength float64) string

func WriteFile ΒΆ

func WriteFile(path string, b []byte) error

func WriteJSON ΒΆ

func WriteJSON(w http.ResponseWriter, v any)

func WriteJSONFS ΒΆ

func WriteJSONFS(path string, b []byte) error

WriteJSONFS takes a JSON value and writes it recursively to the filesystem.

func WriteJSONFile ΒΆ

func WriteJSONFile(path string, v any) error

func WriteMethodNotAllowed ΒΆ

func WriteMethodNotAllowed(w http.ResponseWriter)

func WriteNotFound ΒΆ

func WriteNotFound(w http.ResponseWriter)

func WriteTempFile ΒΆ

func WriteTempFile(b []byte) (string, error)

Types ΒΆ

type API ΒΆ

type API[T any] struct {
	UserDir    string
	SessionDir string
	OrgDir     string
	DataDir    string
	// contains filtered or unexported fields
}

func NewAPI ΒΆ

func NewAPI[T any](workdir string) *API[T]

func (*API[T]) Data ΒΆ

func (api *API[T]) Data() *Table[T]

func (*API[T]) Login ΒΆ

func (api *API[T]) Login(w http.ResponseWriter, r *http.Request)

func (*API[T]) Logout ΒΆ

func (api *API[T]) Logout(w http.ResponseWriter, r *http.Request)

func (*API[T]) NewOrg ΒΆ

func (api *API[T]) NewOrg(w http.ResponseWriter, r *http.Request)

func (*API[T]) Orgs ΒΆ

func (api *API[T]) Orgs() *Table[Org]

func (*API[T]) Register ΒΆ

func (api *API[T]) Register(w http.ResponseWriter, r *http.Request)

func (*API[T]) ServeData ΒΆ

func (api *API[T]) ServeData(w http.ResponseWriter, r *http.Request)

func (*API[T]) ServeHTTP ΒΆ

func (api *API[T]) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*API[T]) Sessions ΒΆ

func (api *API[T]) Sessions() *Table[string]

func (*API[T]) Users ΒΆ

func (api *API[T]) Users() *Table[User]

type Account ΒΆ

type Account struct {
	Phone string
}

type Action ΒΆ

type Action struct {
	Name string
	URL  string
}

func (*Action) HTML ΒΆ

func (a *Action) HTML() *html.Node

type App ΒΆ

type App struct {
	DataDir  string
	Types    map[string]*Type
	RootType *Type
}

func (*App) Get ΒΆ

func (a *App) Get(w http.ResponseWriter, r *http.Request)

func (App) HTMLReader ΒΆ

func (a App) HTMLReader() *HTMLReader

func (*App) ServeHTTP ΒΆ

func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)

type AppConfig ΒΆ

type AppConfig struct {
	Kind string
}

type AppServer ΒΆ

type AppServer struct {
	RootDir string
}

type Array ΒΆ

type Array struct {
	Path  []string
	Value any
}

func (*Array) Dig ΒΆ

func (a *Array) Dig(s string) (Object, bool)

func (*Array) ID ΒΆ

func (a *Array) ID() string

func (*Array) JSON ΒΆ

func (a *Array) JSON() string

func (*Array) Ptr ΒΆ

func (a *Array) Ptr() any

func (*Array) Type ΒΆ

func (a *Array) Type() string

type ArrayType ΒΆ

type ArrayType struct {
	Name        Name                 `json:"name"`
	Description string               `json:"description"`
	ElemType    string               `json:"elem_type"`
	Methods     map[string]*Function `json:"methods"`
	DefaultJSON string               `json:"default_json"`
}

func (*ArrayType) WriteGoFile ΒΆ

func (t *ArrayType) WriteGoFile(path string) error

func (*ArrayType) WriteTypeScriptFile ΒΆ

func (t *ArrayType) WriteTypeScriptFile(path string) error

type AuthMethod ΒΆ

type AuthMethod interface {
	SendLoginCode(phone string) error
	Login(code string) (string, error)
	Logout(token string) error
	WhoAmI(token string) (string, error)
}

type Backend ΒΆ

type Backend struct {
	DataURL   string `json:"dataURL"`
	GoWorkDir string `json:"goWorkDir"`
	BinDir    string `json:"binDir"`
}

func (*Backend) Call ΒΆ

func (backend *Backend) Call(path string, method string, args []string) ([]string, error)

func (*Backend) Get ΒΆ

func (b *Backend) Get(path string) (*Response, error)

type BlogPost ΒΆ

type BlogPost struct {
	Metadata *WebpageMetadata
	BodyHTML string
}

type Bool ΒΆ

type Bool struct {
	Path  []string
	Value bool
}

func (*Bool) Dig ΒΆ

func (b *Bool) Dig(s string) (Object, bool)

func (*Bool) ID ΒΆ

func (b *Bool) ID() string

func (*Bool) JSON ΒΆ

func (b *Bool) JSON() string

func (*Bool) Ptr ΒΆ

func (b *Bool) Ptr() any

func (*Bool) Type ΒΆ

func (b *Bool) Type() string

type BuildConfig ΒΆ

type BuildConfig struct {
	Type      string
	Path      string
	Out       string
	OnSuccess string
}

func (*BuildConfig) Build ΒΆ

func (config *BuildConfig) Build() error

type BuildServer ΒΆ

type BuildServer struct {
	Workdir string
	Config  map[string]*BuildConfig
}

func (*BuildServer) ServeHTTP ΒΆ

func (s *BuildServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

type CI ΒΆ

type CI struct {
	PeriodMinutes int
	SourceDir     string
	OutFile       string
	ServiceName   string
	TwilioClient  *TwilioClient
	AdminPhone    string
}

func (*CI) Codebase ΒΆ

func (ci *CI) Codebase() *GoCodebase

func (*CI) GitRepo ΒΆ

func (ci *CI) GitRepo() *GitRepo

func (*CI) Run ΒΆ

func (ci *CI) Run() (bool, error)

func (*CI) Serivce ΒΆ

func (ci *CI) Serivce() *SystemdService

func (*CI) Start ΒΆ

func (ci *CI) Start()

type Cafe ΒΆ

type Cafe[T http.Handler] struct {
	ID   string
	Data map[string]T
}

type CmdServer ΒΆ

type CmdServer struct {
	Dir string
}

func (*CmdServer) ServeHTTP ΒΆ

func (s *CmdServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Collection ΒΆ

type Collection struct {
	Schema *Schema
	Items  []string
}

func (*Collection) List ΒΆ

func (c *Collection) List(limit, after int)

List returns a list of the first `limit` items after

type DB ΒΆ

type DB struct {
	FS     FileSystem
	Schema struct {
		Tables map[string]struct {
			Columns map[string]string
		}
	}
}

func (*DB) AddColumn ΒΆ

func (db *DB) AddColumn(table, column, typ string) error

func (*DB) CreateTable ΒΆ

func (db *DB) CreateTable(name string) error

func (*DB) Delete ΒΆ

func (db *DB) Delete(name string) error

func (*DB) Insert ΒΆ

func (db *DB) Insert(name string) error

func (*DB) SelectMany ΒΆ

func (db *DB) SelectMany(name string) error

func (*DB) SelectOne ΒΆ

func (db *DB) SelectOne(name string) error

func (*DB) Update ΒΆ

func (db *DB) Update(name string) error

type DevServer ΒΆ

type DevServer struct {
	PkgPath string
	// contains filtered or unexported fields
}

func (*DevServer) Start ΒΆ

func (s *DevServer) Start()

type Email ΒΆ

type Email string

func (Email) Validate ΒΆ

func (email Email) Validate() error

type Endpoint ΒΆ

type Endpoint struct {
	Method      string
	Path        string
	HandlerBody []string
}

type Error ΒΆ

type Error struct {
	Message string
	Actions []Action
}

func (*Error) HTML ΒΆ

func (e *Error) HTML() *html.Node

type Expression ΒΆ

type Expression struct {
	IsLiteral bool   `json:"isLiteral"`
	Value     string `json:"value"`

	IsCall bool          `json:"isCall"`
	Fn     *Ref          `json:"fn"`
	Args   []*Expression `json:"args"`

	IsRef bool `json:"isRef"`
	Ref   *Ref `json:"ref"`
}

func (*Expression) GoImports ΒΆ

func (ex *Expression) GoImports() map[string]bool

func (*Expression) GoString ΒΆ

func (ex *Expression) GoString(imports map[string]string) string

type FancyRoute ΒΆ

type FancyRoute struct {
	Root   http.Handler
	Static map[string]http.Handler

	Catchall *FancyRoute
	VarName  string
}

func (*FancyRoute) ServeHTTP ΒΆ

func (route *FancyRoute) ServeHTTP(w http.ResponseWriter, r *http.Request)

type FancyRouter ΒΆ

type FancyRouter struct {
	// Routes. Each key should start with '/'.
	// To handle the root request, use the key "/".
	// To define a path variable, use square brackets like "/items/[itemID]".
	Routes   map[string]http.Handler
	NotFound http.Handler
}

FancyRouter handles HTTP requests by matching each request to a handler according to Next.js routing conventions.

func (*FancyRouter) SortedRoutes ΒΆ

func (r *FancyRouter) SortedRoutes() []string

type Field ΒΆ

type Field struct {
	Name        Name   `json:"name"`
	Description string `json:"description"`
	Type        *Type  `json:"type"`
}

func (*Field) GoImports ΒΆ

func (f *Field) GoImports() map[string]bool

func (*Field) ID ΒΆ

func (f *Field) ID() string

type File ΒΆ

type File[T any] struct {
	ID    string `json:"id"`
	Type  string `json:"type"`
	Value T      `json:"value"`
}

type FileObject ΒΆ

type FileObject[T Object] struct {
	Path string
}

func (*FileObject[T]) ServeHTTP ΒΆ

func (fo *FileObject[T]) ServeHTTP(w http.ResponseWriter, r *http.Request)

type FileServer ΒΆ

type FileServer struct {
	Root string
}

func (*FileServer) ServeHTTP ΒΆ

func (fs *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

type FileStore ΒΆ

type FileStore struct {
	Workdir string
}

FileStore stores and serves files. To use, set up a directory with an `auth.json` file and a `content` directory.

func (*FileStore) HasAccess ΒΆ

func (fs *FileStore) HasAccess(userID, path string) bool

func (*FileStore) ReadFile ΒΆ

func (fs *FileStore) ReadFile(path string) ([]byte, error)

type FileSystem ΒΆ

type FileSystem interface {
	ReadFile(path string) ([]byte, error)
	ReadDir(path string) ([]string, error)
	IsDir(path string) bool
	IsFile(path string) bool
	WriteFile(path string, b []byte) error
	MakeDir(path string) error
	Remove(path string) error
	Dig(path string) FileSystem
}

type Folder ΒΆ

type Folder struct {
	Files   []string `json:"files"`
	Folders []string `json:"folders"`
}

type Form ΒΆ

type Form struct {
	Name   Name
	Desc   string
	Fields []Field
	Handle http.HandlerFunc
}

func (*Form) ServeHTTP ΒΆ

func (f *Form) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Function ΒΆ

type Function struct {
	Description string      `json:"description"`
	Inputs      []Field     `json:"inputs"`
	Outputs     []Field     `json:"outputs"`
	Body        []Statement `json:"body"`
}

func (*Function) GoImports ΒΆ

func (f *Function) GoImports() map[string]bool

func (*Function) GoString ΒΆ

func (f *Function) GoString(imports map[string]string) string

type GitRepo ΒΆ

type GitRepo struct {
	Dir string
}

func (*GitRepo) AddAll ΒΆ

func (r *GitRepo) AddAll() error

func (*GitRepo) Commit ΒΆ

func (r *GitRepo) Commit(msg string) error

func (*GitRepo) Pull ΒΆ

func (r *GitRepo) Pull() (bool, error)

Pull from the default upstream. Returns true if there were updates, if git prints "Already up to date.", false is returned. Other errors are returned.

func (*GitRepo) Push ΒΆ

func (r *GitRepo) Push() error

type GithubMirror ΒΆ

type GithubMirror struct {
	Workdir string
}

func (*GithubMirror) Pull ΒΆ

func (g *GithubMirror) Pull(repo string) error

func (*GithubMirror) ServeHTTP ΒΆ

func (g *GithubMirror) ServeHTTP(w http.ResponseWriter, r *http.Request)

Handle webhooks from github

type GithubRepository ΒΆ

type GithubRepository struct {
	ID       int    `json:"id"`
	NodeID   string `json:"node_id"`
	FullName string `json:"full_name"`
}

func (*GithubRepository) SyncLocal ΒΆ

func (repo *GithubRepository) SyncLocal(path string) error

type GithubWebhook ΒΆ

type GithubWebhook struct {
	Type string
	ID   int
}

type GithubWebhookRequest ΒΆ

type GithubWebhookRequest struct {
	Zen        string            `json:"zen"`
	HookID     int               `json:"hook_id"`
	Hook       *GithubWebhook    `json:"hook"`
	Repository *GithubRepository `json:"repository"`
}

type GoBuilder ΒΆ

type GoBuilder struct {
	Workdir string
}

func (*GoBuilder) Build ΒΆ

func (builder *GoBuilder) Build(path string, outfile string) error

type GoCodebase ΒΆ

type GoCodebase struct {
	Dir string
}

func (GoCodebase) Build ΒΆ

func (c GoCodebase) Build(outFile string) error

func (*GoCodebase) GitRepo ΒΆ

func (c *GoCodebase) GitRepo() *GitRepo

func (*GoCodebase) UpdateDeps ΒΆ

func (c *GoCodebase) UpdateDeps() (bool, error)

type GoDecl ΒΆ

type GoDecl struct {
	Name       Name      `json:"name"`
	IsType     bool      `json:"isType"`
	Type       *Type     `json:"type"`
	IsFunction bool      `json:"isFunction"`
	Function   *Function `json:"function"`
	IsVar      bool      `json:"isVar"`
	Var        *Value    `json:"var"`
	IsConst    bool      `json:"isConst"`
	Const      *Value    `json:"const"`
}

func (*GoDecl) GoImports ΒΆ

func (decl *GoDecl) GoImports() map[string]bool

func (*GoDecl) String ΒΆ

func (decl *GoDecl) String(imports map[string]string) string

type GoFile ΒΆ

type GoFile struct {
	PkgName    string   `json:"pkgName"`
	ModuleName string   `json:"moduleName"`
	Decls      []GoDecl `json:"decls"`
}

func (*GoFile) GoImports ΒΆ

func (f *GoFile) GoImports() map[string]bool

func (*GoFile) String ΒΆ

func (f *GoFile) String() string

type GoPackage ΒΆ

type GoPackage struct {
	Types map[string]Type
}

type GoWorkspace ΒΆ

type GoWorkspace struct {
	Dir string
}

func (*GoWorkspace) Build ΒΆ

func (w *GoWorkspace) Build(pkg string, o string) error

func (*GoWorkspace) Clone ΒΆ

func (w *GoWorkspace) Clone(pkg string) error

func (*GoWorkspace) Install ΒΆ

func (w *GoWorkspace) Install(pkg string) error

func (*GoWorkspace) Pull ΒΆ

func (w *GoWorkspace) Pull(pkg string) error

func (*GoWorkspace) ServeGithubWebhook ΒΆ

func (ws *GoWorkspace) ServeGithubWebhook(w http.ResponseWriter, r *http.Request)

type HCloudStorageFileSystem ΒΆ

type HCloudStorageFileSystem struct {
	HetznerStorageBoxAddr     string
	HetznerStorageBoxUsername string
	HetznerStorageBoxPassword string
}

func (*HCloudStorageFileSystem) NewSFTPClient ΒΆ

func (fs *HCloudStorageFileSystem) NewSFTPClient() (*sftp.Client, error)

func (*HCloudStorageFileSystem) NewSSHClient ΒΆ

func (fs *HCloudStorageFileSystem) NewSSHClient() (*ssh.Client, error)

type HTMLDocument ΒΆ

type HTMLDocument struct {
	Head *HTMLHead
	Body *html.Node
}

func (*HTMLDocument) Write ΒΆ

func (d *HTMLDocument) Write(w io.Writer) error

type HTMLHead ΒΆ

type HTMLHead struct {
	Title  string
	Desc   string
	Author string
	CSS    string
}

func (*HTMLHead) ServeHTTP ΒΆ

func (h *HTMLHead) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*HTMLHead) Write ΒΆ

func (h *HTMLHead) Write(w io.Writer) (int64, error)

func (*HTMLHead) XML ΒΆ

func (h *HTMLHead) XML() *XML

type HTMLReader ΒΆ

type HTMLReader struct {
	Types map[string]*Type
}

func NewHTMLReader ΒΆ

func NewHTMLReader(types map[string]*Type) *HTMLReader

func (*HTMLReader) Read ΒΆ

func (r *HTMLReader) Read(w io.Writer, t *Type, path string) error

type HTMLTemplateData ΒΆ

type HTMLTemplateData struct {
	Title    string
	Desc     string
	Author   string
	Keywords string
}

type HashCache ΒΆ

type HashCache struct {
	DataDir string
	// contains filtered or unexported fields
}

func (*HashCache) Exists ΒΆ

func (s *HashCache) Exists(hash [32]byte) (bool, error)

func (*HashCache) Read ΒΆ

func (s *HashCache) Read(hash [32]byte) ([]byte, error)

func (*HashCache) ServeHTTP ΒΆ

func (s *HashCache) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ImportMap ΒΆ

type ImportMap map[string]string

ImportMap maps symbols to Go import strings

func (ImportMap) Go ΒΆ

func (im ImportMap) Go() string

func (ImportMap) TypeScript ΒΆ

func (im ImportMap) TypeScript() string

type Int ΒΆ

type Int struct {
	Path  []string
	Value int64
}

func (*Int) Dig ΒΆ

func (i *Int) Dig(s string) (Object, bool)

func (*Int) ID ΒΆ

func (i *Int) ID() string

func (*Int) JSON ΒΆ

func (i *Int) JSON() string

func (*Int) Ptr ΒΆ

func (i *Int) Ptr() any

func (*Int) Type ΒΆ

func (i *Int) Type() string

type JSONFileServer ΒΆ

type JSONFileServer struct {
	Root string
}

func (*JSONFileServer) ServeHTTP ΒΆ

func (fs *JSONFileServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Link struct {
	Name string
	Href string
}

func (*Link) ServeHTTP ΒΆ

func (l *Link) ServeHTTP(w http.ResponseWriter, r *http.Request)
type LinkList struct {
	Links []Link
}

func (*LinkList) ServeHTTP ΒΆ

func (s *LinkList) ServeHTTP(w http.ResponseWriter, r *http.Request)

type List ΒΆ

type List struct {
	Path  string
	Name  string
	Items []ListItem
}

func (*List) ServeHTTP ΒΆ

func (l *List) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ListItem ΒΆ

type ListItem struct {
	ID          string
	Name        string
	Description string
}

type LiveObject ΒΆ

type LiveObject[T http.Handler] struct {
	Path  string
	Value T
	// contains filtered or unexported fields
}

func NewLiveObject ΒΆ

func NewLiveObject[T http.Handler](path string, value T) *LiveObject[T]

func (*LiveObject[T]) Load ΒΆ

func (obj *LiveObject[T]) Load()

func (*LiveObject[T]) Save ΒΆ

func (obj *LiveObject[T]) Save() error

func (*LiveObject[T]) ServeHTTP ΒΆ

func (obj *LiveObject[T]) ServeHTTP(w http.ResponseWriter, r *http.Request)

type LocalFileSystem ΒΆ

type LocalFileSystem struct {
	Root string
}

func (*LocalFileSystem) Dig ΒΆ

func (fs *LocalFileSystem) Dig(path string) FileSystem

func (*LocalFileSystem) IsDir ΒΆ

func (fs *LocalFileSystem) IsDir(path string) bool

func (*LocalFileSystem) IsFile ΒΆ

func (fs *LocalFileSystem) IsFile(path string) bool

func (*LocalFileSystem) MakeDir ΒΆ

func (fs *LocalFileSystem) MakeDir(path string) error

func (*LocalFileSystem) ReadDir ΒΆ

func (fs *LocalFileSystem) ReadDir(path string) ([]string, error)

func (*LocalFileSystem) ReadFile ΒΆ

func (fs *LocalFileSystem) ReadFile(path string) ([]byte, error)

func (*LocalFileSystem) Remove ΒΆ

func (fs *LocalFileSystem) Remove(path string) error

func (*LocalFileSystem) WriteFile ΒΆ

func (fs *LocalFileSystem) WriteFile(path string, b []byte) error

type Map ΒΆ

type Map struct {
	Path  []string
	Value map[string]any
}

func (*Map) Dig ΒΆ

func (m *Map) Dig(s string) (Object, bool)

func (*Map) ID ΒΆ

func (m *Map) ID() string

func (*Map) JSON ΒΆ

func (m *Map) JSON() string

func (*Map) Ptr ΒΆ

func (m *Map) Ptr() any

func (*Map) Type ΒΆ

func (m *Map) Type() string

type MapList ΒΆ

type MapList[T http.Handler] struct {
	ID   string
	Data map[string]T
}

func (*MapList[T]) ServeHTTP ΒΆ

func (m *MapList[T]) ServeHTTP(w http.ResponseWriter, r *http.Request)

type MapType ΒΆ

type MapType struct {
	Name        Name                 `json:"name"`
	Description string               `json:"description"`
	ElemType    string               `json:"elem_type"`
	Methods     map[string]*Function `json:"methods"`
	DefaultJSON string               `json:"default_json"`
}

func (*MapType) WriteGoFile ΒΆ

func (t *MapType) WriteGoFile(path string) error

func (*MapType) WriteTypeScriptFile ΒΆ

func (t *MapType) WriteTypeScriptFile(path string) error

type Metadata ΒΆ

type Metadata struct {
	Type  string
	Types map[string]Type
}

type MethodCall ΒΆ

type MethodCall struct {
	Method string   `json:"m"`
	Args   []string `json:"args"`
}

type Movie ΒΆ

type Movie struct {
	Year    int
	Title   string
	PTPID   string
	FileSHA string
}

type MultiHostServer ΒΆ

type MultiHostServer struct {
	Hosts        map[string]http.Handler
	TwilioClient *TwilioClient
	AdminPhone   string
}

func (*MultiHostServer) HostPolicy ΒΆ

func (s *MultiHostServer) HostPolicy(ctx context.Context, host string) error

func (*MultiHostServer) ServeHTTP ΒΆ

func (s *MultiHostServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*MultiHostServer) Start ΒΆ

func (s *MultiHostServer) Start(email, certDir string) error

type MultiUserAuthHandler ΒΆ

type MultiUserAuthHandler struct {
	AuthFiles FileSystem
	Twilio    *TwilioClient
}

func (*MultiUserAuthHandler) Login ΒΆ

func (a *MultiUserAuthHandler) Login(phone, code string) (*Session, error)

func (*MultiUserAuthHandler) SendLoginCode ΒΆ

func (a *MultiUserAuthHandler) SendLoginCode(phone string) error

func (*MultiUserAuthHandler) ServeHTTP ΒΆ

func (a *MultiUserAuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Name ΒΆ

type Name []Word

func NewName ΒΆ

func NewName(s string) Name

func (Name) GoExported ΒΆ

func (n Name) GoExported() string

GoExported returns an exported Go name. Ex: "Green Button" => "GreenButton"

func (Name) ID ΒΆ

func (n Name) ID() string

ID returns the id friendly string. Ex: "Green Button" => "green_button"

func (Name) PascalCase ΒΆ

func (n Name) PascalCase() string

func (Name) SnakeCase ΒΆ

func (n Name) SnakeCase() string

func (Name) String ΒΆ

func (n Name) String() string

type NextApp ΒΆ

type NextApp struct {
	Favicon     []byte
	StaticFiles map[string][]byte
	Types       map[string]Type
	Constants   map[string]Value
	Functions   map[string]Function
	Hooks       map[string]Function
	Components  map[string]ReactComponent
	Pages       map[string]NextPage
	Layouts     map[string]ReactComponent
}

func (*NextApp) Write ΒΆ

func (na *NextApp) Write(dir string) error

type NextPage ΒΆ

type NextPage struct {
	Name  Name
	State []*Field
	Body  []*Statement
}

func (*NextPage) Write ΒΆ

func (p *NextPage) Write(path string) error

type Nil ΒΆ

type Nil struct {
	Path []string
}

func (*Nil) Dig ΒΆ

func (n *Nil) Dig(p string) (Object, bool)

func (*Nil) ID ΒΆ

func (n *Nil) ID() string

func (*Nil) JSON ΒΆ

func (n *Nil) JSON() string

func (*Nil) Ptr ΒΆ

func (n *Nil) Ptr() any

func (*Nil) Type ΒΆ

func (n *Nil) Type() string

type Object ΒΆ

type Object interface {
	ID() string
	JSON() string
	Type() string
	Ptr() any
	Dig(s string) (Object, bool)
}

func NewObject ΒΆ

func NewObject(path []string, v any) Object

type Org ΒΆ

type Org struct {
	RootDataType string
	Readers      Set[string]
	Writers      Set[string]
}

func (*Org) IsReader ΒΆ

func (o *Org) IsReader(userID string) bool

func (*Org) IsWriter ΒΆ

func (o *Org) IsWriter(userID string) bool

type Pair ΒΆ

type Pair[K, V any] struct {
	K K
	V V
}

type Person ΒΆ

type Person struct {
	FirstName string
	LastName  string
}

func (*Person) FullName ΒΆ

func (p *Person) FullName() string

type Personal ΒΆ

type Personal struct {
	Blog []BlogPost
}

type PhoneNumber ΒΆ

type PhoneNumber string

func (PhoneNumber) Validate ΒΆ

func (phone PhoneNumber) Validate() error

type PingServer ΒΆ

type PingServer struct {
	Msg string
}

func (*PingServer) ServeHTTP ΒΆ

func (s *PingServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

type PostgresDB ΒΆ

type PostgresDB struct {
	User string
	Pass string
	Host string
	DB   string
}

func (*PostgresDB) Open ΒΆ

func (pg *PostgresDB) Open() *sql.DB

type ProgrammingLanguage ΒΆ

type ProgrammingLanguage struct {
	ImportSyntax   string
	TypeSyntax     string
	FunctionSyntax string
	ExportSyntax   string
}

type Prompt ΒΆ

type Prompt struct {
	Name    Name
	Desc    string
	Options []PromptOption
}

func (*Prompt) ServeHTTP ΒΆ

func (p *Prompt) ServeHTTP(w http.ResponseWriter, r *http.Request)

type PromptOption ΒΆ

type PromptOption struct {
	Name Name
	URL  string
}

type ReactComponent ΒΆ

type ReactComponent struct {
	Name  Name
	Props []*Field
	State []*Field
	Body  []*Statement
}

func (*ReactComponent) Write ΒΆ

func (rc *ReactComponent) Write(path string) error

type ReactElement ΒΆ

type ReactElement struct {
	Type  string
	Props []struct {
		Key   string
		Value any
	}
	Children []ReactElement
}

func (*ReactElement) WriteNextJSPage ΒΆ

func (el *ReactElement) WriteNextJSPage(w io.Writer) error

type ReactHook ΒΆ

type ReactHook struct{}

func (*ReactHook) Write ΒΆ

func (h *ReactHook) Write(path string) error

type Ref ΒΆ

type Ref struct {
	From string `json:"from"`
	Name string `json:"name"`
}

func (*Ref) GoImports ΒΆ

func (r *Ref) GoImports() map[string]bool

func (*Ref) GoString ΒΆ

func (r *Ref) GoString(imports map[string]string) string

type RemoteFileSystem ΒΆ

type RemoteFileSystem struct {
	Root string
}

func (*RemoteFileSystem) IsDir ΒΆ

func (fs *RemoteFileSystem) IsDir(path string) bool

func (*RemoteFileSystem) IsFile ΒΆ

func (fs *RemoteFileSystem) IsFile(path string) bool

func (*RemoteFileSystem) MakeDir ΒΆ

func (fs *RemoteFileSystem) MakeDir(path string) error

func (*RemoteFileSystem) ReadDir ΒΆ

func (fs *RemoteFileSystem) ReadDir(path string) ([]string, error)

func (*RemoteFileSystem) ReadFile ΒΆ

func (fs *RemoteFileSystem) ReadFile(path string) ([]byte, error)

func (*RemoteFileSystem) Remove ΒΆ

func (fs *RemoteFileSystem) Remove(path string) error

func (*RemoteFileSystem) WriteFile ΒΆ

func (fs *RemoteFileSystem) WriteFile(path string, b []byte) error

type Request ΒΆ

type Request struct {
	Method string
	URL    string
	Header http.Header
	Body   string
}

func NewRequest ΒΆ

func NewRequest(r *http.Request) *Request

func (*Request) Log ΒΆ

func (r *Request) Log()

type Response ΒΆ

type Response struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

type Route ΒΆ

type Route struct {
	GetRoot  http.HandlerFunc
	PostRoot http.HandlerFunc
	GetID    func(id string, w http.ResponseWriter, r *http.Request)
	PostID   func(id string, w http.ResponseWriter, r *http.Request)
	PutID    func(id string, w http.ResponseWriter, r *http.Request)
	PatchID  func(id string, w http.ResponseWriter, r *http.Request)
	DeleteID func(id string, w http.ResponseWriter, r *http.Request)
}

func (*Route) ServeHTTP ΒΆ

func (route *Route) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Router ΒΆ

type Router struct {
	Root func(w http.ResponseWriter, r *http.Request)
	Next func(first string, w http.ResponseWriter, r *http.Request)
}

func (*Router) ServeHTTP ΒΆ

func (router *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)

type SHA256Server ΒΆ

type SHA256Server struct {
	FileDir string
	User    string
	Pass    string
}

func (*SHA256Server) ServeHTTP ΒΆ

func (s *SHA256Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ScalarType ΒΆ

type ScalarType struct {
	Name        Name                 `json:"name"`
	Description string               `json:"description"`
	ElemType    string               `json:"elemType"`
	Methods     map[string]*Function `json:"methods"`
	DefaultJSON string               `json:"defaultJSON"`
}

func (*ScalarType) WriteGoFile ΒΆ

func (st *ScalarType) WriteGoFile(path string) error

func (*ScalarType) WriteTypeScriptFile ΒΆ

func (st *ScalarType) WriteTypeScriptFile(path string) error

type Schema ΒΆ

type Schema struct {
	Fields []Field
}

func (*Schema) Type ΒΆ

func (s *Schema) Type() *Type

type SchemaCafe ΒΆ

type SchemaCafe struct {
	Schemas map[string]*Schema
}

func (*SchemaCafe) ServeHTTP ΒΆ

func (sc *SchemaCafe) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Sender ΒΆ

type Sender interface {
	Send(to string, msg string) error
}

type Service ΒΆ

type Service struct {
	Name  string            `json:"name"`
	Env   map[string]string `json:"env"`
	Start string            `json:"start"`
	User  string            `json:"user"`
}

func (*Service) Systemd ΒΆ

func (s *Service) Systemd() string

type Session ΒΆ

type Session struct {
	UserID string
	Token  string
}

func (*Session) String ΒΆ

func (s *Session) String() string

type Set ΒΆ

type Set[T comparable] map[T]bool

func (Set[T]) Add ΒΆ

func (s Set[T]) Add(v T)

func (Set[T]) Has ΒΆ

func (s Set[T]) Has(v T) bool

func (Set[T]) Intersection ΒΆ

func (s Set[T]) Intersection(other Set[T]) Set[T]

func (Set[T]) List ΒΆ

func (s Set[T]) List() []T

func (Set[T]) Remove ΒΆ

func (s Set[T]) Remove(v T)

func (Set[T]) Union ΒΆ

func (s Set[T]) Union(other Set[T]) Set[T]

type SheetsDB ΒΆ

type SheetsDB struct {
}

type SimpleForm ΒΆ

type SimpleForm struct {
	TitleText  string
	Fields     []Field
	SubmitText string
	Error      error
	HandlePOST http.HandlerFunc
}

func (*SimpleForm) ServeHTTP ΒΆ

func (form *SimpleForm) ServeHTTP(w http.ResponseWriter, r *http.Request)

type SinglePageApp ΒΆ

type SinglePageApp struct {
	// contains filtered or unexported fields
}

func (*SinglePageApp) ServeHTTP ΒΆ

func (spa *SinglePageApp) ServeHTTP(w http.ResponseWriter, r *http.Request)

type SingleUserApp ΒΆ

type SingleUserApp struct {
	Twilio    *TwilioClient
	UserPhone string
	Files     FileSystem
	Handler   http.Handler
}

func (*SingleUserApp) AuthFiles ΒΆ

func (a *SingleUserApp) AuthFiles() FileSystem

func (*SingleUserApp) AuthHandler ΒΆ

func (a *SingleUserApp) AuthHandler() *SingleUserAuthHandler

func (*SingleUserApp) Authorized ΒΆ

func (a *SingleUserApp) Authorized(r *http.Request) (bool, error)

func (*SingleUserApp) GetSession ΒΆ

func (a *SingleUserApp) GetSession(token string) (*Session, error)

func (*SingleUserApp) ServeHTTP ΒΆ

func (app *SingleUserApp) ServeHTTP(w http.ResponseWriter, r *http.Request)

type SingleUserAuthHandler ΒΆ

type SingleUserAuthHandler struct {
	UserPhone string
	AuthFiles FileSystem
	Twilio    *TwilioClient
}

func (*SingleUserAuthHandler) Login ΒΆ

func (a *SingleUserAuthHandler) Login(phone, code string) (*Session, error)

func (*SingleUserAuthHandler) SendLoginCode ΒΆ

func (a *SingleUserAuthHandler) SendLoginCode(phone string) error

func (*SingleUserAuthHandler) ServeHTTP ΒΆ

type Statement ΒΆ

type Statement struct {
	IsReturn bool        `json:"isReturn"`
	Return   *Expression `json:"return"`

	IsAssign bool        `json:"isAssign"`
	Name     string      `json:"name"`
	Value    *Expression `json:"value"`

	IsIf      bool         `json:"isIf"`
	Condition *Expression  `json:"condition"`
	Body      []*Statement `json:"body"`
}

Statement represents a line of code in a function or method body. There are 4 types of statements: returns, assignments, ifs and loops. Ifs and loops have substatements.

func (*Statement) GoImports ΒΆ

func (s *Statement) GoImports() map[string]bool

func (*Statement) GoString ΒΆ

func (st *Statement) GoString(imports map[string]string, indent int) string

type StreamBroadcaster ΒΆ

type StreamBroadcaster struct {
	ContentType string
	StartFunc   func() (io.ReadCloser, error)
	// contains filtered or unexported fields
}

func NewStreamBroadcaster ΒΆ

func NewStreamBroadcaster(contentType string, startFunc func() (io.ReadCloser, error)) *StreamBroadcaster

func (*StreamBroadcaster) ServeHTTP ΒΆ

func (sb *StreamBroadcaster) ServeHTTP(w http.ResponseWriter, r *http.Request)

type StreamMultiplexer ΒΆ

type StreamMultiplexer struct {
	// contains filtered or unexported fields
}

func NewStreamMultiplexer ΒΆ

func NewStreamMultiplexer(contentType string, backendURL string) *StreamMultiplexer

func (*StreamMultiplexer) ServeHTTP ΒΆ

func (m *StreamMultiplexer) ServeHTTP(w http.ResponseWriter, r *http.Request)

type String ΒΆ

type String struct {
	Path  []string
	Value string
}

func (*String) Dig ΒΆ

func (s *String) Dig(p string) (Object, bool)

func (*String) ID ΒΆ

func (s *String) ID() string

func (*String) JSON ΒΆ

func (s *String) JSON() string

func (*String) Ptr ΒΆ

func (s *String) Ptr() any

func (*String) Type ΒΆ

func (s *String) Type() string

type Struct ΒΆ

type Struct struct {
	Path  []string
	Value map[string]any
}

func (*Struct) Dig ΒΆ

func (s *Struct) Dig(p string) (Object, bool)

func (*Struct) ID ΒΆ

func (s *Struct) ID() string

func (*Struct) JSON ΒΆ

func (s *Struct) JSON() string

func (*Struct) Ptr ΒΆ

func (s *Struct) Ptr() any

func (*Struct) Type ΒΆ

func (s *Struct) Type() string

type StructType ΒΆ

type StructType struct {
	Name        Name                 `json:"name"`
	Description string               `json:"description"`
	Fields      []Field              `json:"fields"`
	Methods     map[string]*Function `json:"methods"`
	DefaultJSON string               `json:"default_json"`
}

func (*StructType) WriteGoFile ΒΆ

func (t *StructType) WriteGoFile(path, pkgName string) error

func (*StructType) WriteTypeScriptFile ΒΆ

func (t *StructType) WriteTypeScriptFile(path string) error

type SystemdService ΒΆ

type SystemdService struct {
	Name        string
	Desc        string
	After       string
	Type        string
	Env         []Pair[string, string]
	ExecStart   string
	AutoRestart string
	WantedBy    string
}

func (*SystemdService) Restart ΒΆ

func (s *SystemdService) Restart() error

func (*SystemdService) WriteConfig ΒΆ

func (s *SystemdService) WriteConfig(w io.Writer) error

func (*SystemdService) WriteConfigToFile ΒΆ

func (s *SystemdService) WriteConfigToFile() error

type TVEpisode ΒΆ

type TVEpisode struct {
	SeasonID  string
	EpisodeID string
}

type TVSeason ΒΆ

type TVSeason struct {
	ID string
}

type TVShow ΒΆ

type TVShow struct {
	Year  int
	Title string
	BTNID string
}

type Table ΒΆ

type Table[T any] struct {
	DataDir  string
	IndexDir string
	Indexes  Set[string]
	// contains filtered or unexported fields
}

func (*Table[T]) Delete ΒΆ

func (t *Table[T]) Delete(id string) error

func (*Table[T]) FindIDsBy ΒΆ

func (t *Table[T]) FindIDsBy(k, v string) (Set[string], error)

func (*Table[T]) Get ΒΆ

func (t *Table[T]) Get(id string) (*T, error)

func (*Table[T]) Len ΒΆ

func (t *Table[T]) Len() int

func (*Table[T]) ListAll ΒΆ

func (t *Table[T]) ListAll() []string

func (*Table[T]) Post ΒΆ

func (t *Table[T]) Post(v *T) error

func (*Table[T]) Set ΒΆ

func (t *Table[T]) Set(id string, v *T) error

type TableConstraint ΒΆ

type TableConstraint struct {
	Col  string
	Uniq bool
}

type TemplateServer ΒΆ

type TemplateServer[DataType any] struct {
	Tmpl    *template.Template
	Workdir string
	UserID  string
}

func NewTemplateServer ΒΆ

func NewTemplateServer[DataType any](tmpl *template.Template, workdir, userID string) *TemplateServer[DataType]

func (*TemplateServer[T]) ServeHTTP ΒΆ

func (s *TemplateServer[T]) ServeHTTP(w http.ResponseWriter, r *http.Request)

type TwilioClient ΒΆ

type TwilioClient struct {
	AccountSID  string
	AuthToken   string
	PhoneNumber string
}

func (*TwilioClient) SendSMS ΒΆ

func (c *TwilioClient) SendSMS(to, message string) error

type Type ΒΆ

type Type struct {
	Description       string               `json:"description"`
	IsScalar          bool                 `json:"isScalar"`
	Scalar            *Ref                 `json:"scalar"`
	IsArray           bool                 `json:"isArray"`
	IsMap             bool                 `json:"isMap"`
	ElemType          *Type                `json:"elemType"`
	IsStruct          bool                 `json:"isStruct"`
	Fields            []Field              `json:"fields"`
	Methods           map[string]*Function `json:"methods"`
	DefaultJSON       string               `json:"defaultJSON"`
	LocalInstanceName string               `json:"localInstanceName"`
}

func (*Type) GoImports ΒΆ

func (t *Type) GoImports() map[string]bool

func (*Type) GoString ΒΆ

func (t *Type) GoString(imports map[string]string) string

type User ΒΆ

type User struct {
	Email        string
	PasswordHash string
}

func (*User) IsPassword ΒΆ

func (u *User) IsPassword(pass string) bool

func (*User) SetPassword ΒΆ

func (u *User) SetPassword(pass string)

type Value ΒΆ

type Value struct {
	Description string `json:"description"`
	Type        *Type  `json:"type"`
	JSON        string `json:"json"`
}

func (*Value) GoImports ΒΆ

func (v *Value) GoImports() map[string]bool

func (*Value) GoString ΒΆ

func (v *Value) GoString(imports map[string]string) string

func (*Value) WriteGoConstFile ΒΆ

func (v *Value) WriteGoConstFile(path string) error

func (*Value) WriteGoVarFile ΒΆ

func (v *Value) WriteGoVarFile(path string) error

func (*Value) WriteReactHookFile ΒΆ

func (v *Value) WriteReactHookFile(path string) error

func (*Value) WriteTypeScriptConstantFile ΒΆ

func (v *Value) WriteTypeScriptConstantFile(path string) error

type Video ΒΆ

type Video struct {
	Height     int
	Width      int
	FPS        int
	Source     string
	VideoCodec string
	AudioCodec string
	Encoder    string
	Container  string
}

type WebAPI ΒΆ

type WebAPI struct {
	Types    map[string]Type
	RootType string
	Data     FileSystem
}

The WebAPI type represents an WebAPI backed by any JSON-serializable Go object.

func (*WebAPI) ServeHTTP ΒΆ

func (api *WebAPI) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves a generic REST API.

func (*WebAPI) ServeNotFound ΒΆ

func (api *WebAPI) ServeNotFound(w http.ResponseWriter, r *http.Request)

func (*WebAPI) ServePOST ΒΆ

func (api *WebAPI) ServePOST(w http.ResponseWriter, r *http.Request)

type WebpageMetadata ΒΆ

type WebpageMetadata struct {
	Title    string
	Desc     string
	Author   *Person
	Keywords []string
	Favicon  []byte
}

type Word ΒΆ

type Word string

func (Word) Lower ΒΆ

func (w Word) Lower() Word

func (Word) String ΒΆ

func (w Word) String() string

func (Word) StripNonAlphaNumeric ΒΆ

func (w Word) StripNonAlphaNumeric() Word

func (Word) Title ΒΆ

func (w Word) Title() Word

func (Word) Upper ΒΆ

func (w Word) Upper() Word

type XML ΒΆ

type XML struct {
	El       string
	Attrs    []Pair[string, string]
	Children []*XML
}

func NewXML ΒΆ

func NewXML(n *html.Node) *XML

func XMLString ΒΆ

func XMLString(s string) *XML

func (*XML) Attr ΒΆ

func (xml *XML) Attr(key string) string

func (*XML) String ΒΆ

func (xml *XML) String() string

func (*XML) Write ΒΆ

func (xml *XML) Write(w io.Writer) (n int64, err error)

Source Files ΒΆ

Directories ΒΆ

Path Synopsis
cmd
jsonreadertest command
jsonwritertest command