This repository has been archived by the owner on Mar 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Standard library
Martin Angers edited this page Sep 12, 2013
·
11 revisions
The standard library is voluntarily small and minimal for this early release. As the language gains features and stabilizes, the right way to offer APIs will become more obvious, and the major use-cases of the language will be better known, allowing for better decisions regarding what makes sense to include in the stdlib.
There are currently seven (7) stdlib modules:
- conv to provide value conversions and type inspection.
-
filepath to provide file path manipulation functions, a subset of Go's
path/filepath
package. -
fmt to provide formatted I/O, a subset of Go's
fmt
package. -
math to provide the usual mathematical functions, a subset of Go's
math
andmath/rand
packages. -
os to provide file access and process manipulation, a subset of Go's
os
,os/exec
andio/ioutil
packages. -
strings to provide string manipulation functions and regular expressions, a subset of Go's
strings
andregexp
packages. -
time to provide date and time functions and types, a subset of Go's
time
package.
The conv
module exposes the following methods:
- Number(val) : converts val to a number, returns the number.
- String(val) : converts val to a string, returns the string.
- Bool(val) : converts val to a boolean, returns the boolean.
-
Type(val) : checks the type of val, returns a string representing the type. The possible return values are
string
,number
,bool
,func
,object
ornil
.
- Abs(val) : returns the absolute path of val. It may panic.
- Base(val) : returns the last element of val.
- Dir(val) : returns all but the last element of val.
- Ext(val) : returns the extension of the last element of val. The extension is the suffix of the last element starting at the last dot.
- IsAbs(val) : returns true if val is an absolute path.
- Join(vals...) : joins any number of path elements into a single path, and returns the resulting path.
Next: Native Go API