util

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2015 License: MIT Imports: 10 Imported by: 6

Documentation

Overview

Package util contains varoius utilities used by MCPM

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadPackage

func DownloadPackage(typ int, pid int, name string, fid int) (string, io.ReadCloser, error)

DownloadPackage allows to download packages. If File ID (fid) equals -1, then it downloads the latest version.

func DownloadPackageInfo

func DownloadPackageInfo(typ int, pid int, name string) (io.ReadCloser, error)

DownloadPackageInfo allows to download information about packages.

func FileSize

func FileSize(size int64) string

FileSize returns a formatted data size in bytes, kilobytes etc.

func FindGo

func FindGo() error

func FindJava

func FindJava() error

func GetHomeDir

func GetHomeDir() string

GetHomeDir returns default MCPM directory. If directory is not set yet, function creates a path to it and checks if it exists.

func MkDirIfNotExist

func MkDirIfNotExist(dir string) error

MkDirIfNotExist checks if a directory exists. If not, it creates one.

func Must

func Must(e error)

Must handles various errors and prints their Go and string values.

func MustClose

func MustClose(cl io.Closer)

MustClose handles io.Closer errors when deferred.

func ReadGobGzip

func ReadGobGzip(file string, v interface{}) error

ReadGobGzip reads gzipped and encoded with gob data from a file and decodes it.

func WriteGobGzip

func WriteGobGzip(file string, v interface{}) error

WriteGobGzip writes gzipped and encoded with gob data to a file.

Types

type PackageOptions

type PackageOptions struct {
	Dir          string
	ShouldUnpack bool
}

func GetPackageOptions

func GetPackageOptions(typ int) *PackageOptions

type ProgressReader

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

ProgressReader is an io.ReadCloser which outputs progress in a terminal.

func NewProgressReader

func NewProgressReader(r io.Reader, total uint64, intro string) *ProgressReader

NewProgressReader returns new ProgressReader.

func (*ProgressReader) Close

func (pr *ProgressReader) Close() error

Close checks if given io.Reader is also an io.Closer. If true, it closes.

func (*ProgressReader) Read

func (pr *ProgressReader) Read(p []byte) (n int, err error)

Read reads data and updates progress.

Jump to

Keyboard shortcuts

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