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

Jump to

Keyboard shortcuts

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