herenow

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 13 Imported by: 0

README

herenow-go

Minimal Go library + CLI for publishing static sites to here.now, anonymously — no account, no API key. Sites live 24 hours.

CLI

go install github.com/lalyos/herenow-go/cmd/hn@latest

hn publish ./dist        # -> https://bitter-crest-rzfn.here.now/
hn publish ./dist        # same URL, only changed files upload
hn publish report.html   # single file -> https://kindly-rapids-swat.here.now/report.html
hn list                  # remembered sites
hn open ./dist           # open in browser

A single file becomes a one-file site served under its own name (an index.html is served at the root instead). Each path — dir or file — keeps its own URL.

Flags: -name (state key), -new (force a new site), -ttl, -title, -json.

State is kept in ~/.herenow/sites/<name>.json, keyed by a hash of the directory's absolute path, and holds the claim token — the only way to update or keep a site. Mode 0600; never commit it.

Library

res, err := herenow.Publish(ctx, os.DirFS("./dist"), herenow.Options{})
fmt.Println(res.SiteURL, res.ClaimURL)

// update the same site later
herenow.Publish(ctx, fsys, herenow.Options{Slug: res.Slug, ClaimToken: res.ClaimToken})

Input is any fs.FS, so embed.FS, zip.Reader and fstest.MapFS work too. Dotfiles are skipped. Files are sha256-hashed so the server skips blobs it already has.

Options also carries DisplayName, TTL, SPAMode, APIKey (for a non-anonymous site), BaseURL and HTTP. Errors from the API unwrap to *herenow.Error (Code, Message, RetryAfter).

Zero dependencies, stdlib only.

Documentation

Overview

Package herenow publishes an fs.FS as a static site on https://here.now.

Anonymous publishing needs no account: sites expire after 24 hours and the returned ClaimToken/ClaimURL is the only way to update or keep them.

Index

Constants

View Source
const DefaultBaseURL = "https://here.now"

DefaultBaseURL is the here.now API root.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Status     int    `json:"-"`
	Code       string `json:"code"`
	Message    string `json:"message"`
	RetryAfter int    `json:"retry_after"`
	DocsURL    string `json:"docs_url"`
}

Error is a structured here.now API error.

func (*Error) Error

func (e *Error) Error() string

type Options

type Options struct {
	// Slug and ClaimToken update an existing anonymous site instead of
	// creating a new one. Both come from a previous Result.
	Slug       string
	ClaimToken string

	DisplayName        string
	DisplayDescription string
	TTL                time.Duration // 0 = server default (24h anonymous)
	SPAMode            bool

	BaseURL string       // defaults to DefaultBaseURL
	HTTP    *http.Client // defaults to http.DefaultClient
	APIKey  string       // optional hnk_… key; empty = anonymous
}

Options tunes a Publish call. The zero value publishes a new anonymous site.

type Result

type Result struct {
	Slug       string     `json:"slug"`
	SiteURL    string     `json:"siteUrl"`
	ClaimURL   string     `json:"claimUrl,omitempty"`
	ClaimToken string     `json:"claimToken,omitempty"`
	ExpiresAt  *time.Time `json:"expiresAt,omitempty"`
	Files      int        `json:"files"`
	Uploaded   int        `json:"uploaded"`
}

Result is a published site.

func Publish

func Publish(ctx context.Context, fsys fs.FS, opt Options) (*Result, error)

Publish uploads every file in fsys and makes it live, returning the site URL.

Directories

Path Synopsis
cmd
hn command
Command hn publishes a directory to here.now and remembers it, so the next publish of the same directory updates the same URL.
Command hn publishes a directory to here.now and remembers it, so the next publish of the same directory updates the same URL.

Jump to

Keyboard shortcuts

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