oututil

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2020 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Indent

func Indent(buf *bytes.Buffer, level int)

Indent prefixes all lines with \t

func PrefixLine

func PrefixLine(buf *bytes.Buffer, prefix string, level int)

PrefixLine prefixes all lines in a buffer

Example
package main

import (
	"bytes"
	"fmt"
	"log"
	"net/http"
	"net/http/httputil"
	"strings"
)

func init() {
	debugging = true
}

func main() {
	const body = "Any seemingly pointless activity which is actually necessary to solve a problem which solves a problem which, several levels of recursion later, solves the real problem you're working on."
	req, err := http.NewRequest("PUT", "https://bovineshave.club", strings.NewReader(body))
	if err != nil {
		log.Fatal(err)
	}

	dump, err := httputil.DumpRequestOut(req, true)
	if err != nil {
		panic(err)
	}
	b := bytes.NewBuffer(dump)
	PrefixLine(b, "> ", 1)
	fmt.Println(b.String())
}
Output:

>  PUT / HTTP/1.1
>  Host: bovineshave.club
>  User-Agent: Go-http-client/1.1
>  Content-Length: 187
>  Accept-Encoding: gzip
>
>  Any seemingly pointless activity which is actually necessary to solve a problem which solves a problem which, several levels of recursion later, solves the real problem you're working on.

func Printf

func Printf(format string, v ...interface{})

Printf prints a message with a header

func Println

func Println(v ...interface{})

Println prints a message with a header and appends a \n

Types

type Direction

type Direction byte

Direction impies the text direction

const (
	// LTR is left to right
	LTR Direction = iota
	// RTL is right to left
	RTL
)

type Point

type Point struct {
	Origin int64
	Length int64
	Dir    Direction
}

Point is a coordinate in text with a length and direction

type SourceError

type SourceError struct {
	File         string
	Line, Column int
	Message      string
}

SourceError represents an errror in the srouce code

func ScanSourceError

func ScanSourceError(message string) []SourceError

ScanSourceError takes the log of a process and returns it's sourcecode errors

Jump to

Keyboard shortcuts

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