본문 바로가기

Go/Packages9

[Go] Package fmt Package fmt implements formatted I/O with functions analogous to C's printf and scanf. Description General %v : the value in a default format (when printing structs, adds the plus symbol to field names ) %#v : a Go-syntax representation of the value %T : a Go-syntax representation of the type of value Integer %b : base 2 %d : base 10 %x : base 16, with lower-case letters for a-f %X : base 16, wi.. 2021. 10. 4.
[Go] Package os Package os provides a platform-independent interface to operating system functionality. The os interface is intended to be uniform across all operating systems. Features not generally available appear in the system-specific package syscall. Constants O_RDONLY : read-only O_WRONLY : write-only O_RDWR : read-write O_APPEND : append data when writing O_CREATE : create if none exists O_EXCL : file m.. 2020. 12. 2.
[Go] Package testing Package testing provides support for automated testing of Go packages. Methods Error Error is equivalent to Log() followed by Fail(). func (c *T) Error(args ...interface{}) Errorf Errorf is equivalent to Logf() followed by Fail(). func (c *T) Errorf(format string, args ...interface{}) Usage package main import "testing" func TestFunction(t *testing.T) { t.Error("Test Failed") } 2020. 11. 30.
[Go] Package log Package log implements a simple logging package. Methods Fatal Fatal is equivalent to Print() followed by a call to os.Exit(1). func Fatal(v ...interface{}) Fatalf Fatalf is equivalent to Printf() followed by a call to os.Exit(1). func Fatalf(format string, v ...interface{}) Fatalln Fatalln is equivalent to Println() followed by a call to os.Exit(1). Panic Panic is equivalent to Print() followed.. 2020. 11. 30.
[Go] Package bufio Package bufio implements buffered I/O. Methods type Scanner 더보기 NewScanner NewScanner returns a new Scanner to read from r. func NewScanner (r io.Reader) *Scanner Err Err returns the first non-EOF error that was encountered by the Scanner. func (s *Scanner) Err() error Scan Scan advances the Scanner to the next token, which will then be available through the Bytes or Text method. It returns fals.. 2020. 10. 31.
[Go] Package errors Package errors implements functions to manipulate errors. Methods New New returns an error that formats as the given text. Each call to New returns a distinct error value even if the text is identical. func New(text string) error Usages package main import ( "errors" "log" ) func main() { err := errors.New("error: my error") if err != nil { log.Fatal(err) } } // error: my error 2020. 10. 29.
[Go] Package math Package math Package math provides basic constants and mathematical functions. Package rand Package rand implements pseudo-random number generators. Methods Seed Seed uses the provided seed value to initialize the default Source to a deterministic state. Seed values that have the same remainder when divided by 2^31 - 1 generate the same pseudo-random sequence. Seed, unlike the Rand.Seed method, .. 2020. 10. 27.
[Go] Package strconv Package strconv implements conversions to and from string representations of basic data types. Methods Atoi Atoi equivalent to ParseInt(s, 10, 0), converted to type int. func Atoi(s string) (int, error) Itoa Itoa is equivalent to FormatInt. func Itoa(i int) string ParseBool, ParseUInt, ParseInt, ParseFloat ParseBool, ParseUInt, ParseInt, and ParseFloat convert strings to values. func ParseBool(s.. 2020. 10. 26.
[Go] Package strings Package strings implements simple functions to manipulate UTF-8 encoded strings. Methods TrimSpace TrimSpace returns a slice of the string, with all leading and trailing white space removed, as defined by Unicode. func TrimSpace(s string) string Usages package main import ( "fmt" "strings" ) func main() { greeting := "\n Hi, nice to meet you \t\n" fmt.Println(strings.TrimSpace(greeting)) // Hi, .. 2020. 10. 26.