godoc 명령
godoc 명령어를 입력하면 Go 공식 문서를 로컬 웹 서버에서 볼 수 있다.
C:\>godoc -http=:8000
명령 프롬프트에 명령을 입력하여 실행한 후 웹 브라우저에서 http://localhost:8000로 접속하면 Go 공식 문서를 로컬 웹 서버에서 볼 수 있다. godoc 명령을 로컬 웹 서버로 실행하면 현재 PC에 받았던 외부 패키지에 대한 문서도 함께 보여준다.
특정 패키지나 함수의 정보를 간단하게 확인할 때는 명령 프롬프트에 godoc 패키지명 함수명 명령을 입력한다. 명령 프롬프트에서 godoc fmt Fprintf를 입력하여 실행하면 fmt.Fprintf() 함수에 대한 문서를 보여준다
C:>godoc fmt Fprintf
func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) Fprintf formats according to a format specifier and writes to w. It returns the number of bytes written and any write error encountered.
godoc image/png를 입력하고 실행하면 image/png 패키지 전체 정보를 명령 프롬프트에서 보여준다.
C:>godoc image/png
godoc image/png
PACKAGE DOCUMENTATION
package png
import "image/png"
Package png implements a PNG image decoder and encoder.
The PNG specification is at http://www.w3.org/TR/PNG/.
FUNCTIONS
func Decode(r io.Reader) (image.Image, error) Decode reads a PNG image from r and returns it as an image.Image. The type of Image returned depends on the PNG contents.
func DecodeConfig(r io.Reader) (image.Config, error) DecodeConfig returns the color model and dimensions of a PNG image without decoding the entire image.
func Encode(w io.Writer, m image.Image) error Encode writes the Image m to w in PNG format. Any Image may be encoded, but images that are not image.NRGBA might be encoded lossily.
TYPES
type CompressionLevel int
const (
DefaultCompression CompressionLevel = 0
NoCompression CompressionLevel = -1
NBestSpeed CompressionLevel = -2
NBestCompression CompressionLevel = -3
)
type Encoder struct {
CompressionLevel CompressionLevel
}
Encoder configures encoding PNG images.
func (enc *Encoder) Encode(w io.Writer, m image.Image) error Encode writes the Image m to w in PNG format.
type FormatError string
A FormatError reports that the input is not a valid PNG.
func (e FormatError) Error() string
type UnsupportedError string
An UnsupportedError reports that the input uses a valid but unimplemented PNG feature.
func (e UnsupportedError) Error() string