util

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile added in v0.3.0

func CopyFile(src, dst string) (int64, error)

CopyFile copy content of src to dst credit to https://opensource.com/article/18/6/copying-files-go

func DecodeFromResponse added in v0.4.3

func DecodeFromResponse(resp *http.Response) (raw *bytes.Reader, img image.Image, format string, err error)

DecodeFromResponse return picture in http response

func DoAndExpectType added in v0.4.3

func DoAndExpectType(req *http.Request, expected string) (*http.Response, error)

DoAndExpectType sends request to server and expects response with specified content type

func DoAndReadJSON added in v0.4.3

func DoAndReadJSON(req *http.Request, obj interface{}) error

DoAndReadJSON sends request and parse its JSON response

func ExecutableFolder

func ExecutableFolder() string

ExecutableFolder returns path to the folder containing currently running executable file

func Get added in v0.4.3

func Get(url string) (*http.Response, error)

Get a response from specified URL

func GetInType

func GetInType(url, expected string) (*http.Response, error)

GetInType sends a GET request and expects a response with certain content type

func Head(url string, followRedirection bool) (*http.Response, error)

Head sends requests with HEAD method

func IsReachableLink(url string) bool

IsReachableLink checks reachability of URL

func ReadJSON

func ReadJSON(url string, obj interface{}) error

ReadJSON send a GET request to URL and parse its JSON response

func RemoveFilesByGlob added in v0.3.0

func RemoveFilesByGlob(pattern string, confirm ConfirmRemove) error

RemoveFilesByGlob deletes all files matching a specified glob pattern

func Viewpoint added in v0.4.2

func Viewpoint(w0, h0 float64) (w, h float64)

Viewpoint returns the visible region of a image after being centered and filling the desktop

Types

type ConfirmRemove added in v0.3.0

type ConfirmRemove func(path string) bool

type RegistryMap

type RegistryMap map[string]interface{}

RegistryMap keeps any registrable pairs

func (RegistryMap) Get

func (m RegistryMap) Get(name string) (v interface{}, ok bool)

Get a registered item

func (*RegistryMap) Register

func (m *RegistryMap) Register(name string, v interface{})

Register an item

Jump to

Keyboard shortcuts

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