Go Language FAQ

No 1-3 Semua (balik urutan) |

yuku@gofaq : 2009-11-25 09:22:10 UTC+0000
How to "import static" like in Java? (No need to put package qualifier to access keywords)

Use dot as the alias of the import.

For example:

import . "fmt"

Now you can access Printf without typing fmt.Printf.
yuku@gofaq : 2009-11-25 09:28:15 UTC+0000
How to read from standard input and write to standard output?

os.Stdin and os.Stdout acts as automatically opened os.File, so you can read and write
to it. They are automatically io.Writer and io.Reader too, because they implement

func (file *File) Write(b []byte) (n int, err Error)
  and
func (file *File) Read(b []byte) (n int, err Error)

There is os.Stderr too.
yuku@gofaq : 2009-11-25 09:55:52 UTC+0000
How to convert byte slice to string, string to characters, and so on? (Go)

Convert []byte to string:

string(bytes)

Convert characters in []int to string:

string(characters)

Convert a character to string:

string(character) // string of length 1

Convert string to []byte:

strings.Bytes(s)

 

Kau akan ngepos secara anonim! Boleh2 aja sih, bahkan tulis nama dan sembarang paswod pun boleh. Tapi kalo mau daftar, klik daftar

Nama Pwd gp jsp dua+dua= +img +coret

 

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|