common

package
v0.0.0-...-98571d4 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2020 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package common implements methods and variables that do not fit into any other package and are mostly independent of this repository.

Index

Constants

View Source
const (

	// ServerV112 is the download link for a pre-made 1.12 Minecraft Server.
	ServerV112 = "http://" + provider + "/mcserver-backend/dl/1.12.zip"

	// ServerV18 is the download link for a pre-made 1.8 Minecraft Server.
	ServerV18 = "http://" + provider + "/mcserver-backend/dl/1.8.zip"

	// ServerV172 is the download link for a pre-made 1.7.2 Minecraft Server.
	ServerV172 = "http://" + provider + "/mcserver-backend/dl/1.7.2.zip"

	// ServerV121 is the download link for a pre-made 1.2.1 Minecraft Server.
	ServerV121 = "http://" + provider + "/mcserver-backend/dl/1.2.1.zip"
)
View Source
const ServerIDSize = 8

ServerIDSize is the length of server IDs.

Variables

View Source
var (
	// DataDir is the root directory for all server data.
	DataDir = "data"

	// ServersRoot is the root directory where all of the servers are stored.
	ServersRoot = path.Join(DataDir, "servers")

	// APIServerRoot is the default root route for the API server.
	APIServerRoot = "/api"
)

Functions

func CreateDirIfDoesNotExist

func CreateDirIfDoesNotExist(dir string) error

CreateDirIfDoesNotExist creates a directory if it does not already exist.

func DownloadServer

func DownloadServer(url, localPath, version string) (string, error)

DownloadServer downloads and installs a pre-made server of the specified version.

func NewLogger

func NewLogger(context string) *loggo.Logger

NewLogger will create a new default loggo.Logger.

func NewServerPath

func NewServerPath(name string) (string, error)

NewServerPath returns the path to a server given its name.

func Unzip

func Unzip(src string, dest string) ([]string, error)

Unzip decompresses a zip archive, moving all files and folders within the zip file (src) to an output directory (dest).

Types

type Hash

type Hash struct {
	Hash []byte `json:"hash"`
}

Hash represents an Sha3 hash.

func Sha3

func Sha3(b []byte) Hash

Sha3 hashes a byte input using Sha3.

func (*Hash) String

func (hash *Hash) String() string

String encodes a Hash to a string.

Jump to

Keyboard shortcuts

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