modsite

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

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

Go to latest
Published: Sep 21, 2025 License: MIT Imports: 15 Imported by: 0

README

go.tkw01536.de

A static site built via go that holds my personal go modules.

Build via:

go run ./builder

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildSite

func BuildSite(url string, indexContent template.HTML, footerContent template.HTML, modules []Module) (files map[string]string, err error)

BuildSite builds a map of filepath to html content for an html site containing the given modules.

Types

type Module

type Module struct {
	ImportPath string // ImportPath of the module.

	VCSType string
	RepoURL string

	HomePage string // URL to the homepage

	DirectoryLinkTemplate string
	FileLinkTemplate      string
}

Module holds information for a go module with a custom VCSPath. See Module.GoImport and Module.GoSource.

func GitForgeModule

func GitForgeModule(ImportPath string, RepoURL string, ref string) Module

GitForgeModule returns a new Module using templates for a common git forge.

ImportPath is the import path of the module. RepoURL is the https clone url of the repository. Ref should be the git reflike pointing to HEAD. This is typically a branch name.

func (Module) GoImport

func (mod Module) GoImport() string

GoImport returns the value of the "go-import" tag in the [format supported by the go command].

If the struct contains invalid data, returns the empty string instead.

func (Module) GoImportTag

func (mod Module) GoImportTag() template.HTML

GoImportTag renders this module information into a "go-import" meta tag. If this module contains invalid information, returns the empty string instead.

See Module.GoImport for details.

func (Module) GoSource

func (mod Module) GoSource() string

GoSource returns the value of the "go-source" meta tag in the specified format supported by godoc.

Templates for building a link to a source directory and file are derived from the [Module.DirectoryLinkTemplate] and [Module.FileLinkTemplate] fields.

Both templates may contain the following placeholders:

- "{dir}": The import path with prefix and leading "/" trimmed. - "{/dir}": If {dir} is not the empty string, then {/dir} is replaced by "/" + {dir}. Otherwise, {/dir} is replaced with the empty string.

The SourceFileTemplate may additionally contain the following placeholders:

- "{file}": The name of the file. - "{line}": The decimal line number.

As a special case, if [Module.HomePage] is the empty string, falls back to the defaults of godoc.

If the data is invalid, returns the empty string.

func (Module) GoSourceTag

func (mod Module) GoSourceTag() template.HTML

GoSourceTag renders this module information into a "go-source" meta tag. If this module contains invalid information, returns the empty string instead.

See Module.GoSource for details.

func (Module) HomePageURL

func (mod Module) HomePageURL() string

func (Module) RenderSite

func (mod Module) RenderSite(footer template.HTML, w io.Writer, buf *bytes.Buffer) error

RenderSite renders the site template for the given footer. output is written to w. buf is used as an intermediate buffer and should be empty.

func (Module) SourceCodeURL

func (mod Module) SourceCodeURL() string

func (Module) ValidateGoImport

func (mod Module) ValidateGoImport() error

ValidateGoImport checks if this module can generate a "go-module" meta tag and returns a non-nil error if not.

func (Module) ValidateGoSource

func (mod Module) ValidateGoSource() error

ValidateGoSource checks if this module can generate a "go-source" meta tag and returns a non-nil error if not.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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