util

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Plain segmentKind = iota
	DirectLinkURL
	BracketText
)

Variables

This section is empty.

Functions

func CommonPrefix added in v0.5.4

func CommonPrefix(x, y string) string

func HttpRequest added in v0.2.7

func HttpRequest(method, url string, body []byte, timeoutSeconds int, settings ...RequestSetup) (int, http.Header, []byte, error)

Returns: status code, headers, body, error

func IsAsciiLetter added in v0.5.4

func IsAsciiLetter(r rune) bool

func MemoryUse

func MemoryUse() string

func OpenBrowser

func OpenBrowser(url string) error

func RunShell added in v0.2.7

func RunShell(timeout time.Duration, wd string, envs []string, cmdAndArgs ...string) ([]byte, error)

func RunShellCommand

func RunShellCommand(timeout time.Duration, wd string, envs []string, cmd string, args ...string) ([]byte, error)

func ServeFiles

func ServeFiles(dir, recommendedPort string, silentMode bool, goldsVersion string)

func UncompressTarGzipData

func UncompressTarGzipData(data []byte) ([]byte, error)

This function is very simple. It is intended to get a single file.

func WorkingDirectory added in v0.2.7

func WorkingDirectory() string

func WriteHtmlEscapedBytes added in v0.4.1

func WriteHtmlEscapedBytes(w io.Writer, data []byte)

Please make sure w.Write never makes errors.

func WriteUrlEscapedString added in v0.5.4

func WriteUrlEscapedString(w io.StringWriter, data string)

Please make sure w.Write never makes errors.

Types

type HTMLEscapeWriter added in v0.4.1

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

func NewHTMLEscapeWriter added in v0.5.4

func NewHTMLEscapeWriter(w io.Writer) *HTMLEscapeWriter

func (*HTMLEscapeWriter) Write added in v0.4.1

func (he *HTMLEscapeWriter) Write(data []byte) (n int, err error)

func (*HTMLEscapeWriter) WriteString added in v0.5.4

func (he *HTMLEscapeWriter) WriteString(data string) (n int, err error)

Please make sure w.Write never makes errors.

type IndentWriter added in v0.2.8

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

func NewIndentWriter added in v0.2.8

func NewIndentWriter(w io.Writer, indent []byte) *IndentWriter

func (*IndentWriter) Write added in v0.2.8

func (iw *IndentWriter) Write(s []byte) (int, error)

type MarkdownRenderer added in v0.5.4

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

A MarkdownRenderer is used to render docs and comments. It only builds links. Even for building links, it is not fully compatiable with https://go.dev/doc/comment.

## Test case 1

std lib type: io.Reader std lib funciton: fmt.Println current package type: StopWatch current package funciton: MemoryUse, [trimEndingSpaces] current package selector: [MarkdownRenderer.freeSegments], MarkdownRenderer.Render slibing package function: [app.Main], [app.run] slibing package slector: [server.TypeForListing.IsPointer], [server.TypeForListing.InCurrentPkg] module top-level package type: [*code.Package], module top-level package funciton: [code.ComparePackagePaths], [code.getMatchedPackages]

## Test case 2

The following texts are for testing purpose.

Test 1 bla bla. Ref: https://example.com/?a=b#something Test Test Test 222

func (*MarkdownRenderer) Render added in v0.5.4

func (render *MarkdownRenderer) Render(w interface {
	io.StringWriter
	io.Writer
}, mdText string, indent string, removeLineCommonPrefix bool, makeURL func(string) string)

type RequestSetup added in v0.2.7

type RequestSetup func(*http.Request, *http.Client)

type StopWatch

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

func NewStopWatch

func NewStopWatch() *StopWatch

Return an auto-start StopWatch.

func (*StopWatch) Duration

func (sw *StopWatch) Duration(reset bool) (d time.Duration)

Duration will reset the StopWatch.

type URLEscapeWriter added in v0.5.4

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

func NewURLEscapeWriter added in v0.5.4

func NewURLEscapeWriter(w io.StringWriter) *URLEscapeWriter

func (*URLEscapeWriter) WriteString added in v0.5.4

func (ue *URLEscapeWriter) WriteString(data string) (n int, err error)

Jump to

Keyboard shortcuts

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