├── .gitignore ├── README.md ├── archive ├── README.md ├── tar │ ├── README.md │ ├── Reader.md │ └── Writer.md └── zip │ ├── README.md │ ├── Reader.md │ └── Writer.md ├── bufio ├── NewReader.md ├── NewReaderSize.md ├── NewWriter.md ├── NewWriterSize.md ├── README.md ├── ReadWriter.md ├── Reader_Buffered.md ├── Reader_Peek.md ├── Reader_Read.md ├── Reader_ReadByte.md ├── Reader_ReadBytes.md ├── Reader_ReadLine.md ├── Reader_ReadRune.md ├── Reader_ReadSlice.md ├── Reader_ReadString.md ├── Reader_UnreadByte.md ├── Reader_UnreadRune.md ├── Writer_Available.md ├── Writer_Buffered.md ├── Writer_Flush.md ├── Writer_Write.md ├── Writer_WriteByte.md ├── Writer_WriteRune.md └── Writer_WriteString.md ├── build.go ├── builtin ├── ComplexType.md ├── FloatType.md ├── IntegerType.md ├── README.md ├── Type.md ├── Type1.md ├── any.md ├── append.md ├── bool.md ├── byte.md ├── cap.md ├── clear.md ├── close.md ├── comparable.md ├── complex.md ├── complex128.md ├── complex64.md ├── copy.md ├── delete.md ├── error.md ├── float32.md ├── float64.md ├── imag.md ├── int.md ├── int16.md ├── int32.md ├── int64.md ├── int8.md ├── iota.md ├── len.md ├── make.md ├── max.md ├── min.md ├── new.md ├── nil.md ├── panic.md ├── print.md ├── println.md ├── real.md ├── recover.md ├── rune.md ├── string.md ├── uint.md ├── uint16.md ├── uint32.md ├── uint64.md ├── uint8.md └── uintptr.md ├── bytes ├── IndexFunc.md ├── Buffer_Bytes.md ├── Buffer_Len.md ├── Buffer_Next.md ├── Buffer_Read.md ├── Buffer_ReadByte.md ├── Buffer_ReadBytes.md ├── Buffer_ReadFrom.md ├── Buffer_ReadRune.md ├── Buffer_ReadString.md ├── Buffer_Reset.md ├── Buffer_String.md ├── Buffer_Truncate.md ├── Buffer_UnreadByte.md ├── Buffer_UnreadRune.md ├── Buffer_Write.md ├── Buffer_WriteByte.md ├── Buffer_WriteRune.md ├── Buffer_WriteString.md ├── Buffer_WriteTo.md ├── Compare.md ├── Contains.md ├── Count.md ├── Equal.md ├── EqualFold.md ├── Fields.md ├── FieldsFunc.md ├── HasPrefix.md ├── HasSuffix.md ├── Index.md ├── IndexAny.md ├── IndexByte.md ├── IndexRune.md ├── Join.md ├── LastIndex.md ├── LastIndexAny.md ├── LastIndexFunc.md ├── Map.md ├── NewBuffer.md ├── NewBufferString.md ├── NewReader.md ├── README.md ├── Reader_Len.md ├── Reader_Read.md ├── Reader_ReadAt.md ├── Reader_ReadByte.md ├── Reader_ReadRune.md ├── Reader_Seek.md ├── Reader_UnreadByte.md ├── Reader_UnreadRune.md ├── Repeat.md ├── Replace.md ├── Runes.md ├── Split.md ├── SplitAfter.md ├── SplitAfterN.md ├── SplitN.md ├── Title.md ├── ToLower.md ├── ToLowerSpecial.md ├── ToUpper.md ├── ToUpperSpecial.md ├── Trim.md ├── TrimFunc.md ├── TrimLeft.md ├── TrimLeftFunc.md ├── TrimRight.md ├── TrimRightFunc.md └── TrimSpace.md ├── compress ├── README.md ├── bzip2 │ ├── NewReader.md │ ├── README.md │ └── StructuralError.Error.md ├── flate │ ├── CorruptInputError.Error.md │ ├── InternalError.Error.md │ ├── NewReader.md │ ├── NewReaderDict.md │ ├── NewWriter.md │ ├── NewWriterDict.md │ ├── README.md │ ├── ReadError.Error.md │ ├── WriteError.Error.md │ ├── Writer.Close.md │ ├── Writer.Flush.md │ ├── Writer.Reset.md │ └── Writer.Write.md ├── gzip │ ├── README.md │ ├── Reader.md │ └── Writer.md ├── lzw │ ├── NewReader.md │ ├── NewWriter.md │ └── README.md └── zlib │ └── README.md ├── container ├── README.md ├── heap │ ├── Init.md │ ├── Interface.md │ ├── Pop.md │ ├── Push.md │ ├── README.md │ └── Remove.md ├── list │ ├── Back.md │ ├── Element.md │ ├── Front.md │ ├── Init.md │ ├── InsertAfter.md │ ├── InsertBefore.md │ ├── Len.md │ ├── List.md │ ├── MoveToBack.md │ ├── MoveToFront.md │ ├── New.md │ ├── Next.md │ ├── Prev.md │ ├── PushBack.md │ ├── PushBackList.md │ ├── PushFront.md │ ├── PushFrontList.md │ ├── README.md │ └── Remove.md └── ring │ ├── Do.md │ ├── Len.md │ ├── Link.md │ ├── Move.md │ ├── New.md │ ├── Next.md │ ├── Prev.md │ ├── README.md │ ├── Ring.md │ └── Unlink.md ├── crypto ├── README.md ├── aes │ ├── Constants.md │ ├── KeySizeError.Error.md │ ├── KeySizeError.md │ ├── NewCipher.md │ └── README.md ├── cipher │ └── README.md ├── des │ ├── Constants.md │ ├── KeySizeError.Error.md │ ├── KeySizeError.md │ ├── NewCipher.md │ ├── NewTripleDESCipher.md │ └── README.md ├── dsa │ └── README.md ├── ecdsa │ └── README.md ├── elliptic │ └── README.md ├── hmac │ ├── New.md │ └── README.md ├── md5 │ ├── Constants.md │ ├── New.md │ └── README.md ├── rand │ └── README.md ├── rc4 │ ├── Cipher.md │ ├── KeySizeError.Error.md │ ├── KeySizeError.md │ ├── NewCipher.md │ ├── README.md │ ├── Reset.md │ └── XORKeyStream.md ├── rsa │ └── README.md ├── sha1 │ ├── Constants.md │ ├── New.md │ └── README.md ├── sha256 │ ├── New.md │ ├── New224.md │ └── README.md ├── sha512 │ ├── New.md │ ├── New384.md │ └── README.md ├── subtle │ ├── ConstantTimeByteEq.md │ ├── ConstantTimeCompare.md │ ├── ConstantTimeCopy.md │ ├── ConstantTimeEq.md │ ├── ConstantTimeSelect.md │ └── README.md ├── tls │ └── README.md └── x509 │ ├── README.md │ └── pkix │ └── README.md ├── database ├── README.md └── sql │ ├── README.md │ └── driver │ └── README.md ├── debug ├── README.md ├── dwarf │ └── README.md ├── elf │ └── README.md ├── gosym │ └── README.md ├── macho │ └── README.md └── pe │ └── README.md ├── encoding ├── README.md ├── ascii85 │ └── README.md ├── asn1 │ └── README.md ├── base32 │ ├── CorruptInputError.md │ ├── Decode.md │ ├── DecodeString.md │ ├── DecodedLen.md │ ├── Encode.md │ ├── EncodeToString.md │ ├── EncodedLen.md │ ├── NewDecoder.md │ ├── NewEncoder.md │ ├── NewEncoding.md │ ├── README.md │ └── examples │ │ ├── CorruptInputError.mdpp │ │ ├── CorruptInputError_test.go │ │ ├── Decode.mdpp │ │ ├── DecodeString.mdpp │ │ ├── DecodeString_test.go │ │ ├── Decode_test.go │ │ ├── DecodedLen.mdpp │ │ ├── DecodedLen_test.go │ │ ├── Encode.mdpp │ │ ├── EncodeToString.mdpp │ │ ├── EncodeToString_test.go │ │ ├── Encode_test.go │ │ ├── EncodedLen.mdpp │ │ ├── EncodedLen_test.go │ │ ├── NewDecoder.mdpp │ │ ├── NewDecoder_test.go │ │ ├── NewEncoder.mdpp │ │ ├── NewEncoder_test.go │ │ ├── NewEncoding.mdpp │ │ ├── NewEncoding_test.go │ │ └── README.mdpp ├── base64 │ ├── CorruptInputError.md │ ├── Decode.md │ ├── DecodeString.md │ ├── DecodedLen.md │ ├── Encode.md │ ├── EncodeToString.md │ ├── EncodedLen.md │ ├── NewDecoder.md │ ├── NewEncoder.md │ ├── NewEncoding.md │ ├── README.md │ └── examples │ │ ├── CorruptInputError.mdpp │ │ ├── CorruptInputError_test.go │ │ ├── Decode.mdpp │ │ ├── DecodeString.mdpp │ │ ├── DecodeString_test.go │ │ ├── Decode_test.go │ │ ├── DecodedLen.mdpp │ │ ├── DecodedLen_test.go │ │ ├── Encode.mdpp │ │ ├── EncodeToString.mdpp │ │ ├── EncodeToString_test.go │ │ ├── Encode_test.go │ │ ├── EncodedLen.mdpp │ │ ├── EncodedLen_test.go │ │ ├── NewDecoder.mdpp │ │ ├── NewDecoder_test.go │ │ ├── NewEncoder.mdpp │ │ ├── NewEncoder_test.go │ │ ├── NewEncoding.mdpp │ │ ├── NewEncoding_test.go │ │ └── README.mdpp ├── binary │ ├── PutUvarint.md │ ├── PutVarint.md │ ├── README.md │ ├── Read.md │ ├── ReadUvarint.md │ ├── ReadVarint.md │ ├── Size.md │ ├── Uvarint.md │ ├── Varint.md │ └── Write.md ├── csv │ ├── Error.md │ ├── Flush.md │ ├── NewReader.md │ ├── NewWriter.md │ ├── README.md │ ├── Read.md │ ├── ReadAll.md │ ├── Write.md │ └── WriteAll.md ├── gob │ ├── Decode.md │ ├── Decode_Encode.go │ ├── Encode.md │ ├── NewDecoder.md │ ├── NewEncoder.md │ ├── README.md │ ├── gob.go │ └── struct.md ├── hex │ └── README.md ├── json │ ├── Compact.md │ ├── Decode.md │ ├── Encode.md │ ├── HTMLEscape.md │ ├── Indent.md │ ├── Marshal.md │ ├── MarshalIndent.md │ ├── NewDecoder.md │ ├── NewEncoder.md │ ├── README.md │ ├── TestHTMLEscape.go │ ├── Unmarshal.md │ └── json ├── pem │ └── README.md └── xml │ ├── Escape.md │ ├── Marshal.md │ ├── MarshalIndent.md │ └── README.md ├── errors ├── New.md └── README.md ├── expvar ├── README.md ├── testExpvar.go └── vars.json ├── flag ├── Arg.md ├── Args.md ├── Bool.md ├── BoolVar.md ├── Duration.md ├── DurationVar.md ├── FlagSetArg.md ├── FlagSetArgs.md ├── FlagSetBool.md ├── FlagSetBoolVar.md ├── FlagSetDuration.md ├── FlagSetFloat64.md ├── FlagSetFloat64Var.md ├── FlagSetInit.md ├── FlagSetInt.md ├── FlagSetInt64.md ├── FlagSetInt64Var.md ├── FlagSetIntVar.md ├── FlagSetLookup.md ├── FlagSetNArg.md ├── FlagSetNFlag.md ├── FlagSetParse.md ├── FlagSetParsed.md ├── FlagSetPrintDefaults.md ├── FlagSetSet.md ├── FlagSetSetOutput.md ├── FlagSetString.md ├── FlagSetStringVar.md ├── FlagSetUint.md ├── FlagSetUint64.md ├── FlagSetUint64Var.md ├── FlagSetUintVar.md ├── FlagSetVar.md ├── FlagSetVisit.md ├── FlagSetVisitAll.md ├── Float64.md ├── Float64Var.md ├── Int.md ├── Int64.md ├── Int64Var.md ├── IntVar.md ├── Lookup.md ├── NArg.md ├── NFlag.md ├── NewFlagSet.md ├── Parse.md ├── Parsed.md ├── PrintDefaults.md ├── README.md ├── Set.md ├── String.md ├── StringVar.md ├── Uint.md ├── Uint64.md ├── Uint64Var.md ├── UintVar.md ├── Var.md ├── Visit.md └── VisitAll.md ├── fmt ├── Errorf.md ├── Exfmt01.go ├── Exfmt02.go ├── Exfmt03.go ├── Exfmt04.go ├── Exfmt05.go ├── FormatDoc.md ├── Fprint.md ├── Fprintf.md ├── Fprintln.md ├── Fscan.md ├── Fscanf.md ├── Fscanln.md ├── Print.md ├── Printf.md ├── Println.md ├── README.md ├── Scan.md ├── Scanf.md ├── Scanln.md ├── Sprint.md ├── Sprintf.md ├── Sprintln.md ├── Sscan.md ├── Sscanf.md └── Sscanln.md ├── go ├── README.md ├── ast │ └── README.md ├── build │ └── README.md ├── doc │ └── README.md ├── parser │ └── README.md ├── printer │ └── README.md ├── scanner │ └── README.md └── token │ └── README.md ├── hash ├── README.md ├── adler32 │ └── README.md ├── crc32 │ └── README.md ├── crc64 │ └── README.md ├── fnv │ └── README.md └── hashtool.go ├── html ├── EscapeString.md ├── README.md ├── UnescapeString.md └── template │ ├── HTMLEscape.md │ ├── HTMLEscapeString.md │ ├── HTMLEscaper.md │ └── README.md ├── image ├── README.md ├── color │ └── README.md ├── draw │ └── README.md ├── gif │ └── README.md ├── jpeg │ └── README.md └── png │ └── README.md ├── index ├── README.md └── suffixarray │ ├── Bytes.md │ ├── FindAllIndex.md │ ├── Lookup.md │ ├── New.md │ ├── README.md │ ├── Read.md │ └── Write.md ├── io ├── Copy.md ├── CopyN.md ├── LimitReader.Read.md ├── LimitReader.md ├── MultiReader.Read.md ├── MultiReader.md ├── MultiWriter.Write.md ├── MultiWriter.md ├── NewSectionReader.md ├── Pipe.md ├── PipeReader.Close.md ├── PipeReader.CloseWithError.md ├── PipeReader.Read.md ├── PipeWriter.Close.md ├── PipeWriter.CloseWithError.md ├── PipeWriter.Write.md ├── README.md ├── ReadAtLeast.md ├── ReadFull.md ├── SectionReader.Read.md ├── SectionReader.ReadAt.md ├── SectionReader.Seek.md ├── SectionReader.Size.md ├── TeeReader.Read.md ├── TeeReader.md ├── WriteString.md └── ioutil │ ├── NopCloser.md │ ├── README.md │ ├── ReadAll.md │ ├── ReadDir.md │ ├── ReadFile.md │ ├── TempDir.md │ └── TempFile.md ├── log ├── Constants.md ├── Fatal.md ├── Fatalf.md ├── Fatalln.md ├── Flags.md ├── New.md ├── Output.md ├── Panic.md ├── Panicf.md ├── Panicln.md ├── Prefix.md ├── Print.md ├── Printf.md ├── Println.md ├── README.md ├── SetFlags.md ├── SetOutput.md ├── SetPrefix.md ├── lFatal.md ├── lFatalf.md ├── lFatalln.md ├── lFlags.md ├── lPanic.md ├── lPanicf.md ├── lPanicln.md ├── lPrefix.md ├── lPrint.md ├── lPrintf.md ├── lPrintln.md ├── lSetFlags.md ├── lSetPrefix.md └── syslog │ └── README.md ├── math ├── README.md ├── big │ └── README.md ├── cmplx │ └── README.md └── rand │ ├── ExpFloat64.md │ ├── Float32.md │ ├── Float64.md │ ├── Int.md │ ├── Int31.md │ ├── Int31n.md │ ├── Int63.md │ ├── Int63n.md │ ├── Intn.md │ ├── New.md │ ├── NewSource.md │ ├── NewZipf.md │ ├── NormFloat64.md │ ├── Perm.md │ ├── README.md │ ├── Rand-ExpFloat64.md │ ├── Rand-Float32.md │ ├── Rand-Float64.md │ ├── Rand-Int.md │ ├── Rand-Int31.md │ ├── Rand-Int31n.md │ ├── Rand-Int63.md │ ├── Rand-Int63n.md │ ├── Rand-Intn.md │ ├── Rand-NormFloat64.md │ ├── Rand-Perm.md │ ├── Rand-Seed.md │ ├── Rand-Uint32.md │ ├── Rand.md │ ├── Seed.md │ ├── Source.md │ ├── Uint32.md │ ├── Zipf-Uint64.md │ └── Zipf.md ├── mime ├── README.md └── multipart │ └── README.md ├── net ├── Addr.md ├── AddrError.md ├── CIDRMask.md ├── Conn.md ├── DNSConfigError.md ├── DNSError.md ├── Dial.md ├── DialIP.md ├── DialTimeout.md ├── Error.md ├── FileListener.md ├── Flags.md ├── HardwareAddr.md ├── IP.md ├── IPAddr.md ├── IPConn.md ├── IPMask.md ├── IPNet.md ├── IPv4.md ├── IPv4Mask.md ├── Interface.md ├── InterfaceAddrs.md ├── InterfaceByIndex.md ├── InterfaceByName.md ├── Interfaces.md ├── InvalidAddrError.md ├── JoinHostPort.md ├── Listen.md ├── ListenIP.md ├── Listener.md ├── LookupAddr.md ├── LookupCNAME.md ├── LookupHost.md ├── LookupIP.md ├── LookupMX.md ├── LookupPort.md ├── LookupSRV.md ├── LookupTXT.md ├── MX.md ├── OpError.md ├── ParseCIDR.md ├── ParseIP.md ├── ParseMAC.md ├── Pipe.md ├── README.md ├── ResolveIPAddr.md ├── SplitHostPort.md ├── UDPAddr.md ├── http │ ├── CanonicalHeaderKey.md │ ├── DetectContentType.md │ ├── Error.md │ ├── Handle.md │ ├── ListenAndServe.md │ ├── ListenAndServeTLS.md │ ├── MaxBytesReader.md │ ├── NotFound.md │ ├── ParseHTTPVersion.md │ ├── ProxyFromEnvironment.md │ ├── ProxyURL.md │ ├── README.md │ ├── Redirect.md │ ├── Serve.md │ ├── ServeContent.md │ ├── ServeFile.md │ ├── SetCookie.md │ ├── StatusText.md │ ├── cgi │ │ └── README.md │ ├── fcgi │ │ └── README.md │ ├── httptest │ │ └── README.md │ ├── httputil │ │ └── README.md │ └── pprof │ │ └── README.md ├── mail │ ├── Address.md │ ├── ExampleAddress.go │ ├── ExampleMessage.go │ ├── Header.md │ ├── Message.md │ └── README.md ├── rpc │ ├── Accept.md │ ├── Client_Call.md │ ├── Client_Go.md │ ├── Dial.md │ ├── DialHTTP.md │ ├── DialHTTPPath.md │ ├── HandleHTTP.md │ ├── NewClient.md │ ├── NewClientWithCodec.md │ ├── NewServer.md │ ├── README.md │ ├── Register.md │ ├── RegisterName.md │ ├── ServeCodec.md │ ├── ServeConn.md │ ├── ServeRequest.md │ ├── Serve_Accept.md │ ├── Serve_HandleHTTP.md │ ├── Serve_Register.md │ ├── Serve_RegisterName.md │ ├── Serve_ServeCodec.md │ ├── Serve_ServeConn.md │ ├── Serve_ServeHTTP.md │ ├── Serve_ServeRequest.md │ ├── Server_Accept.md │ ├── Server_HandleHTTP.md │ ├── Server_Register.md │ ├── Server_RegisterName.md │ ├── Server_ServeCodec.md │ ├── Server_ServeConn.md │ ├── Server_ServeHTTP.md │ ├── Server_ServeRequest.md │ └── jsonrpc │ │ └── README.md ├── smtp │ ├── Auth.md │ ├── Client.md │ ├── ExampleSmtpClient.go │ ├── ExampleSmtpSendMail.go │ ├── README.md │ └── SendMail.md ├── textproto │ └── README.md └── url │ ├── ParseQuery.md │ ├── QueryEscape.md │ ├── QueryUnescape.md │ └── README.md ├── os ├── Chdir.md ├── Chmod.md ├── Chown.md ├── Chtimes.md ├── Clearenv.md ├── Environ.md ├── Exit.md ├── Expand.md ├── ExpandEnv.md ├── FileInfo_Lstat.md ├── FileInfo_Stat.md ├── FileMode_IsDir.md ├── FileMode_Perm.md ├── FileMode_String.md ├── File_Chdir.md ├── File_Chmod.md ├── File_Chown.md ├── File_Close.md ├── File_Create.md ├── File_Fd.md ├── File_Name.md ├── File_NewFile.md ├── File_Open.md ├── File_OpenFile.md ├── File_Pipe.md ├── File_Read.md ├── File_ReadAt.md ├── File_Readdir.md ├── File_Seek.md ├── File_Stat.md ├── File_Sync.md ├── File_Truncate.md ├── File_Write.md ├── File_WriteAt.md ├── File_WriteString.md ├── Getegid.md ├── Getenv.md ├── Geteuid.md ├── Getgid.md ├── Getgroups.md ├── Getpagesize.md ├── Getpid.md ├── Getppid.md ├── Getuid.md ├── Getwd.md ├── Hostname.md ├── IsExist.md ├── IsNotExist.md ├── IsPathSeparator.md ├── IsPermission.md ├── Lchown.md ├── Link.md ├── LinkError_Error.md ├── Mkdir.md ├── MkdirAll.md ├── NewSyscallError.md ├── PathError_Error.md ├── ProcessState_Exited.md ├── ProcessState_Pid.md ├── ProcessState_String.md ├── ProcessState_Success.md ├── ProcessState_Sys.md ├── ProcessState_SysUsage.md ├── ProcessState_SystemTime.md ├── ProcessState_UserTime.md ├── Process_FindProcess.md ├── Process_Release.md ├── Process_Signal.md ├── Process_StartProcess.md ├── Process_Wait.md ├── Process_kill.md ├── README.md ├── Readlink.md ├── Remove.md ├── RemoveAll.md ├── Rename.md ├── SameFile.md ├── Setenv.md ├── Symlink.md ├── SyscallError_Error.md ├── TempDir.md ├── Truncate.md ├── exec │ ├── CombinedOutput.md │ ├── Command.md │ ├── Error.md │ ├── ExitError.md │ ├── LookPath.md │ ├── Output.md │ ├── README.md │ ├── Run.md │ ├── Start.md │ ├── StderrPipe.md │ ├── StdinPipe.md │ ├── StdoutPipe.md │ └── Wait.md ├── signal │ ├── Notify.md │ └── README.md └── user │ ├── Current.md │ ├── Lookup.md │ ├── LookupId.md │ └── README.md ├── path ├── Base.md ├── Clean.md ├── Dir.md ├── Ext.md ├── IsAbs.md ├── Join.md ├── Match.md ├── README.md ├── Split.md └── filepath │ ├── Abs.md │ ├── Base.md │ ├── Clean.md │ ├── Dir.md │ ├── EvalSymlinks.md │ ├── Ext.md │ ├── FromSlash.md │ ├── Glob.md │ ├── HasPrefix.md │ ├── IsAbs.md │ ├── Join.md │ ├── Match.md │ ├── README.md │ ├── Rel.md │ ├── Split.md │ ├── SplitList.md │ ├── ToSlash.md │ ├── VolumeName.md │ └── Walk.md ├── reflect ├── Append.md ├── AppendSlice.md ├── ChanDir.md ├── ChanOf.md ├── Copy.md ├── DeepEqual.md ├── Indirect.md ├── Kind.md ├── MakeChan.md ├── MakeFunc.md ├── MakeMap.md ├── MakeSlice.md ├── MapOf.md ├── Method.md ├── New.md ├── NewAt.md ├── PtrTo.md ├── README.md ├── Select.md ├── SelectCase.md ├── SelectDir.md ├── SliceHeader.md ├── SliceOf.md ├── StringHeader.md ├── StructField.md ├── Type.Align.md ├── Type.AssignableTo.md ├── Type.Bits.md ├── Type.ChanDir.md ├── Type.ConvertibleTo.md ├── Type.Elem.md ├── Type.Field.md ├── Type.FieldAlign.md ├── Type.FieldByIndex.md ├── Type.FieldByName.md ├── Type.FieldByNameFunc.md ├── Type.Implements.md ├── Type.In.md ├── Type.IsVariadic.md ├── Type.Key.md ├── Type.Kind.md ├── Type.Len.md ├── Type.Method.md ├── Type.MethodByName.md ├── Type.Name.md ├── Type.NumField.md ├── Type.NumIn.md ├── Type.NumMethod.md ├── Type.NumOut.md ├── Type.Out.md ├── Type.PkgPath.md ├── Type.Size.md ├── Type.String.md ├── Type.md ├── TypeOf.md ├── Value.Addr.md ├── Value.Bool.md ├── Value.Bytes.md ├── Value.Call.md ├── Value.CallSlice.md ├── Value.CanAddr.md ├── Value.CanInterface.md ├── Value.CanSet.md ├── Value.Cap.md ├── Value.Close.md ├── Value.Complex.md ├── Value.Convert.md ├── Value.Elem.md ├── Value.Field.md ├── Value.FieldByIndex.md ├── Value.FieldByName.md ├── Value.FieldByNameFunc.md ├── Value.Float.md ├── Value.Index.md ├── Value.Int.md ├── Value.Interface.md ├── Value.InterfaceData.md ├── Value.IsNil.md ├── Value.IsValid.md ├── Value.Kind.md ├── Value.Len.md ├── Value.MapIndex.md ├── Value.MapKeys.md ├── Value.Method.md ├── Value.MethodByName.md ├── Value.NumField.md ├── Value.NumMethod.md ├── Value.OverflowComplex.md ├── Value.OverflowFloat.md ├── Value.OverflowInt.md ├── Value.OverflowUint.md ├── Value.Pointer.md ├── Value.Recv.md ├── Value.Send.md ├── Value.Set.md ├── Value.SetBool.md ├── Value.SetBytes.md ├── Value.SetComplex.md ├── Value.SetFloat.md ├── Value.SetInt.md ├── Value.SetLen.md ├── Value.SetMapIndex.md ├── Value.SetPointer.md ├── Value.SetString.md ├── Value.SetUint.md ├── Value.Slice.md ├── Value.String.md ├── Value.TryRecv.md ├── Value.TrySend.md ├── Value.Type.md ├── Value.Uint.md ├── Value.UnsafeAddr.md ├── Value.md ├── ValueOf.md └── Zero.md ├── regexp ├── README.md └── syntax │ └── README.md ├── runtime ├── README.md ├── cgo │ └── README.md ├── debug │ └── README.md └── pprof │ └── README.md ├── sort ├── Float64Slice.md ├── Float64s.md ├── Float64sAreSorted.md ├── IntSlice.md ├── Interface.md ├── Ints.md ├── IntsAreSorted.md ├── IsSorted.md ├── README.md ├── Reverse.md ├── Search.md ├── SearchFloat64s.md ├── SearchInts.md ├── SearchStrings.md ├── Sort.md ├── Stable.md ├── StringSlice.md ├── Strings.md └── StringsAreSorted.md ├── strconv ├── AppendBool.md ├── AppendFloat.md ├── AppendInt.md ├── AppendQuote.md ├── AppendQuoteRune.md ├── AppendQuoteRuneToASCII.md ├── AppendUint.md ├── Atoi.md ├── CanBackquote.md ├── FormatBool.md ├── FormatFloat.md ├── FormatInt.md ├── FormatUint.md ├── IsPrint.md ├── Itoa.md ├── NumError.Error.md ├── ParseBool.md ├── ParseFloat.md ├── ParseInt.md ├── ParseUint.md ├── Quote.md ├── QuoteRune.md ├── QuoteRuneToASCII.md ├── README.md ├── Unquote.md └── UnquoteChar.md ├── strings ├── Contains.md ├── ContainsAny.md ├── ContainsRune.md ├── Count.md ├── EqualFold.md ├── Fields.md ├── FieldsFunc.md ├── HasPrefix.md ├── HasSuffix.md ├── Index.md ├── IndexAny.md ├── IndexFunc.md ├── IndexRune.md ├── Join.md ├── LastIndex.md ├── LastIndexAny.md ├── LastIndexFunc.md ├── Map.md ├── NewReader.md ├── NewReplacer.md ├── README.md ├── Repeat.md ├── Replace.md ├── Split.md ├── SplitAfter.md ├── SplitAfterN.md ├── SplitN.md ├── Title.md ├── ToLower.md ├── ToLowerSpecial.md ├── ToTitle.md ├── ToTitleSpecial.md ├── ToUpper.md ├── ToUpperSpecial.md ├── Trim.md ├── TrimFunc.md ├── TrimLeft.md ├── TrimLeftFunc.md ├── TrimRight.md ├── TrimRightFunc.md └── TrimSpace.md ├── sync ├── README.md ├── atomic │ ├── AddInt32.md │ ├── README.md │ ├── compareandswapint32.md │ ├── loadint32.md │ └── storeint32.md ├── cond.md ├── mutex.md ├── once.md ├── rwmutex.md ├── type_locker.md └── waitgroup.md ├── syscall └── README.md ├── testing ├── B.md ├── B_Error.md ├── B_Errorf.md ├── B_Fail.md ├── B_FailNow.md ├── B_Failed.md ├── B_Fatal.md ├── B_Fatalf.md ├── B_Log.md ├── B_Logf.md ├── B_ResetTimer.md ├── B_SetBytes.md ├── B_StartTimer.md ├── B_StopTimer.md ├── Benchmark.md ├── BenchmarkResult.md ├── BenchmarkResult_NsPerOp.md ├── BenchmarkResult_String.md ├── InternalBenchmark.md ├── InternalExample.md ├── InternalTest.md ├── Main.md ├── README.md ├── RunBenchmarks.md ├── RunExamples.md ├── RunTests.md ├── Short.md ├── T.md ├── T_Error.md ├── T_Errorf.md ├── T_Fail.md ├── T_FailNow.md ├── T_Failed.md ├── T_Fatal.md ├── T_Fatalf.md ├── T_Log.md ├── T_Logf.md ├── T_Parallel.md ├── iotest │ └── README.md └── quick │ └── README.md ├── text ├── README.md ├── scanner │ ├── Constants.md │ ├── Init.md │ ├── IsValid.md │ ├── Next.md │ ├── Peek.md │ ├── Pos.md │ ├── Position.md │ ├── README.md │ ├── Scan.md │ ├── String.md │ ├── TokenString.md │ └── TokenText.md ├── tabwriter │ └── README.md └── template │ ├── README.md │ └── parse │ └── README.md ├── time ├── Add.md ├── AddDate.md ├── After.md ├── AfterFunc.md ├── Constants.md ├── Duration.md ├── Error.md ├── FixedZone_Editing.md ├── Format.md ├── GobDecode.md ├── GobEncode.md ├── Hours.md ├── ISOWeek.md ├── In.md ├── LoadLocation.md ├── Local.md ├── Location.md ├── MarshalJSON.md ├── Minutes.md ├── Month.md ├── Nanoseconds.md ├── NewTicker.md ├── NewTimer.md ├── Now.md ├── Parse.md ├── ParseDuration.md ├── ParseError.md ├── README.md ├── Seconds.md ├── Since.md ├── Sleep.md ├── Stop.md ├── String.md ├── Sub.md ├── Tick.md ├── Ticker.md ├── Time.md ├── Timer.md ├── UTC.md ├── Unix.md ├── UnixNano.md ├── UnmarshalJSON.md ├── Weekday.md └── Zone.md ├── todo.md ├── unicode ├── README.md ├── utf16 │ ├── Decode.md │ ├── DecodeRune.md │ ├── Encode.md │ ├── EncodeRune.md │ ├── IsSurrogate.md │ └── README.md └── utf8 │ └── README.md └── unsafe └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /archive/README.md: -------------------------------------------------------------------------------- 1 | # Archive 2 | 3 | 二级包列表 4 | 5 | - [archive/tar](tar) 6 | - [archive/zip](zip) -------------------------------------------------------------------------------- /bufio/Reader_ReadByte.md: -------------------------------------------------------------------------------- 1 | ## func (b *Reader) ReadByte() (c byte, err error) 2 | 3 | 返回值 4 | 5 | - c 读取的字节 6 | - err 错误 7 | 8 | 功能说明 9 | 10 | - 读取并返回一个字节。如果没有字节可读,则返回错误。 11 | 12 | 代码示例 13 | 14 | package main 15 | 16 | import ( 17 | "bytes" 18 | "bufio" 19 | "fmt" 20 | ) 21 | 22 | func main() { 23 | rb := bytes.NewBuffer([]byte("12345678")) 24 | r := bufio.NewReader(rb) 25 | b, err := r.ReadByte() 26 | fmt.Printf("%c, %v\n", b, err) 27 | } 28 | 29 | 代码输出 30 | 31 | 1, 32 | 33 | 34 | -------------------------------------------------------------------------------- /bufio/Writer_Available.md: -------------------------------------------------------------------------------- 1 | ## func (b *Writer) Available() int 2 | 3 | 返回值 4 | 5 | - int 字节数 6 | 7 | 功能说明 8 | 9 | - Available返回缓冲区中未使用的字节数 10 | 11 | 代码示例 12 | 13 | package main 14 | 15 | import ( 16 | "bufio" 17 | "bytes" 18 | "fmt" 19 | ) 20 | 21 | func main() { 22 | wb := bytes.NewBuffer(nil) 23 | w := bufio.NewWriter(wb) 24 | fmt.Println(w.Available()) 25 | w.WriteByte('1') 26 | fmt.Println(w.Available()) 27 | } 28 | 29 | 代码输出 30 | 31 | 4096 32 | 4095 33 | -------------------------------------------------------------------------------- /bufio/Writer_Buffered.md: -------------------------------------------------------------------------------- 1 | ## func (b *Writer) Buffered() int 2 | 3 | 返回值 4 | 5 | - int 字节数 6 | 7 | 功能说明 8 | 9 | - 返回已写入当前缓冲区中的字节数 10 | 11 | 代码示例 12 | 13 | package main 14 | 15 | import ( 16 | "bufio" 17 | "bytes" 18 | "fmt" 19 | ) 20 | 21 | func main() { 22 | wb := bytes.NewBuffer(nil) 23 | w := bufio.NewWriter(wb) 24 | fmt.Println(w.Buffered()) 25 | w.WriteByte('1') 26 | fmt.Println(w.Buffered()) 27 | w.Flush() 28 | fmt.Println(w.Buffered()) 29 | } 30 | 31 | 代码输出 32 | 33 | 0 34 | 1 35 | 0 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /bufio/Writer_WriteByte.md: -------------------------------------------------------------------------------- 1 | ## func (b *Writer) WriteByte(c byte) error 2 | 3 | 参数说明 4 | 5 | - c 要写入的字节 6 | 7 | 返回值 8 | 9 | - error 错误 10 | 11 | 功能说明 12 | 13 | - 写入一个字节 14 | 15 | 代码示例 16 | 17 | package main 18 | 19 | import ( 20 | "bufio" 21 | "bytes" 22 | "fmt" 23 | ) 24 | 25 | func main() { 26 | wb := bytes.NewBuffer(nil) 27 | w := bufio.NewWriter(wb) 28 | w.WriteByte('a') 29 | w.Flush() 30 | fmt.Println(string(wb.Bytes())) 31 | } 32 | 33 | 代码输出 34 | 35 | a 36 | -------------------------------------------------------------------------------- /builtin/ComplexType.md: -------------------------------------------------------------------------------- 1 | ## type ComplexType complex64 2 | 3 | 功能说明: 4 | 5 | ComplexType 在此只用作文档目的。 它代表所有的复数类型:即 complex64 或 complex128。 -------------------------------------------------------------------------------- /builtin/FloatType.md: -------------------------------------------------------------------------------- 1 | ## type FloatType float32 2 | 3 | 功能说明: 4 | 5 | FloatType 在此只用作文档目的。 它代表所有的浮点数类型:即 float32 或 float64。 -------------------------------------------------------------------------------- /builtin/IntegerType.md: -------------------------------------------------------------------------------- 1 | ## type IntegerType int 2 | 3 | 功能说明: 4 | 5 | IntegerType 在此只用作文档目的。 它代表所有的整数类型:如 int、uint、int8 等。 -------------------------------------------------------------------------------- /builtin/Type.md: -------------------------------------------------------------------------------- 1 | ## type Type int 2 | 3 | 功能说明: 4 | 5 | Type 在此只用作文档目的。 它代表所有Go的类型,但对于任何给定的函数请求来说,它都代表与其相同的类型。 -------------------------------------------------------------------------------- /builtin/Type1.md: -------------------------------------------------------------------------------- 1 | ## type Type1 int 2 | 3 | 功能说明: 4 | 5 | Type1 在此只用作文档目的。 它代表所有Go的类型,但对于任何给定的函数请求来说,它都代表与其相同的类型。 -------------------------------------------------------------------------------- /builtin/any.md: -------------------------------------------------------------------------------- 1 | ## type any = interface{} 2 | 3 | 功能说明: 4 | 5 | any是interface{}的别名,二者在所有方面都相等。 6 | -------------------------------------------------------------------------------- /builtin/bool.md: -------------------------------------------------------------------------------- 1 | ## type bool bool 2 | 3 | 功能说明: 4 | 5 | bool 是布尔值的集合,即 true 和 false。 -------------------------------------------------------------------------------- /builtin/byte.md: -------------------------------------------------------------------------------- 1 | ## type byte byte 2 | 3 | 功能说明: 4 | 5 | byte 为 uint8 的别名,它完全等价于 uint8。 习惯上用它来区别字节值和8位无符号整数值。 -------------------------------------------------------------------------------- /builtin/cap.md: -------------------------------------------------------------------------------- 1 | ## func cap(v Type) int 2 | 3 | 参数列表: 4 | 5 | - v Type 6 | 7 | 返回值: 8 | 9 | - int 10 | 11 | 功能说明: 12 | 13 | cap 内建函数返回 v 的容量,返回值取决 v 的具体类型: 14 | 15 | 数组:v 中元素的数量(与 len(v) 相同)。 16 | 17 | 数组指针:*v 中元素的数量(与 len(v) 相同)。 18 | 19 | 切片:在重新切片时,切片能够达到的最大缓存长度;若 v 为 nil,len(v) 即为零。 20 | 21 | 信道:以信道元素数量为单位返回信道缓存容量;若 v 为 nil,len(v) 即为零。 22 | -------------------------------------------------------------------------------- /builtin/comparable.md: -------------------------------------------------------------------------------- 1 | ## type comparable interface{ comparable } 2 | 3 | 功能说明: 4 | 5 | comparable 是所有可比较类型实现的接口。只能用作类型参数约束,不能作为变量的类型。 6 | -------------------------------------------------------------------------------- /builtin/complex.md: -------------------------------------------------------------------------------- 1 | ## func complex(r, i FloatType) ComplexType 2 | 3 | 参数列表: 4 | 5 | - r FloatType 实部 6 | - i FloatType 虚部 7 | 8 | 返回值: 9 | 10 | - ComplexType 11 | 12 | 功能说明: 13 | 14 | complex 内建函数将两个浮点数值构造成一个复数值。 其实部和虚部的大小必须相同,即 float32 或 float64(或可赋予它们的),其返回值 即为对应的复数类型(complex64 对应 float32,complex128 对应 float64)。 15 | 16 | 代码实例: 17 | 18 | ```go 19 | package main 20 | 21 | import "fmt" 22 | 23 | func main() { 24 | fmt.Println(complex(10, 2)) 25 | } 26 | ``` 27 | 28 | 输出: 29 | 30 | ~~~ 31 | (10+2i) 32 | ~~~ -------------------------------------------------------------------------------- /builtin/complex128.md: -------------------------------------------------------------------------------- 1 | ## type complex128 complex128 2 | 3 | 功能说明: 4 | 5 | complex128 是所有实部和虚部为 float64 的复数集合。 -------------------------------------------------------------------------------- /builtin/complex64.md: -------------------------------------------------------------------------------- 1 | ## type complex64 complex64 2 | 3 | 功能说明: 4 | 5 | complex64 是所有实部和虚部为 float32 的复数集合。 -------------------------------------------------------------------------------- /builtin/error.md: -------------------------------------------------------------------------------- 1 | ## type error 2 | ~~~go 3 | type error interface { 4 | Error() string 5 | } 6 | ~~~ 7 | 8 | 功能说明: 9 | 10 | error 内建接口类型是表示错误情况的约定接口,nil 值即表示没有错误。 -------------------------------------------------------------------------------- /builtin/float32.md: -------------------------------------------------------------------------------- 1 | ## type float32 float32 2 | 3 | 功能说明: 4 | 5 | float32 是所有IEEE-754 32位浮点数的集合。 -------------------------------------------------------------------------------- /builtin/float64.md: -------------------------------------------------------------------------------- 1 | ## type float64 float64 2 | 3 | 功能说明: 4 | 5 | float64 是所有IEEE-754 64位浮点数的集合。 -------------------------------------------------------------------------------- /builtin/imag.md: -------------------------------------------------------------------------------- 1 | ## func imag(c ComplexType) FloatType 2 | 3 | 参数列表: 4 | 5 | - c ComplexType 复数 6 | 7 | 返回值: 8 | 9 | - FloatType 复数 c 的虚部 10 | 11 | 功能说明: 12 | 13 | imag 内建函数返回复数 c 的虚部。 返回值类型与 c 的浮点类型对应。 14 | 15 | 代码实例: 16 | 17 | ```go 18 | package main 19 | 20 | import "fmt" 21 | 22 | func main() { 23 | fmt.Println(imag(10 + 2i)) 24 | } 25 | ``` 26 | 27 | 输出: 28 | 29 | ~~~ 30 | 2 31 | ~~~ -------------------------------------------------------------------------------- /builtin/int.md: -------------------------------------------------------------------------------- 1 | ## type int int 2 | 3 | 功能说明: 4 | 5 | int 是带符号整数类型,其大小至少为32位。 它是一种确切的类型,而不是 int32 的别名。 -------------------------------------------------------------------------------- /builtin/int16.md: -------------------------------------------------------------------------------- 1 | ## type int16 int16 2 | 3 | 功能说明: 4 | 5 | int16 是所有带符号16位整数的集合。 范围:-32768 至 32767。 -------------------------------------------------------------------------------- /builtin/int32.md: -------------------------------------------------------------------------------- 1 | ## type int32 int32 2 | 3 | 功能说明: 4 | 5 | int32 是所有带符号32位整数的集合。范围: -2147483648 至 2147483647。 -------------------------------------------------------------------------------- /builtin/int64.md: -------------------------------------------------------------------------------- 1 | ## type int64 int64 2 | 3 | 功能说明: 4 | 5 | int64 是所有带符号64位整数的集合。 范围:-9223372036854775808 至 9223372036854775807。 -------------------------------------------------------------------------------- /builtin/int8.md: -------------------------------------------------------------------------------- 1 | ## type int8 int8 2 | 3 | 功能说明: 4 | 5 | int8 是所有带符号8位整数的集合。 范围:-128 至 127。 -------------------------------------------------------------------------------- /builtin/len.md: -------------------------------------------------------------------------------- 1 | ## func len(v Type) int 2 | 3 | 参数列表: 4 | 5 | - v Type 要计算的值 6 | 7 | 返回值: 8 | 9 | - int 返回 v 的长度 10 | 11 | 功能说明: 12 | 13 | len 内建函数返回 v 的长度,这取决于具体类型: 14 | 15 | ~~~ 16 | 数组:v 中元素的数量。 17 | 数组指针:*v 中元素的数量(即使 v 为 nil)。 18 | 切片或映射:v 中元素的数量;若 v 为 nil,len(v) 即为零。 19 | 字符串:v 中字节的数量。 20 | 信道:信道缓存中队列(未读取)元素的数量;若 v 为 nil,len(v) 即为零。 21 | ~~~ -------------------------------------------------------------------------------- /builtin/new.md: -------------------------------------------------------------------------------- 1 | ## func new(Type) *Type 2 | 3 | 参数列表: 4 | 5 | - Type 6 | 7 | 返回值: 8 | 9 | - *Type 10 | 11 | 功能说明: 12 | 13 | new 内建函数分配内存。 其第一个实参为类型,而非值,其返回值为指向该类型新分配的零值的指针。 14 | 15 | 代码实例: 16 | 17 | ~~~go 18 | package main 19 | 20 | import "fmt" 21 | 22 | type Vertex struct { 23 | X, Y int 24 | } 25 | 26 | func main() { 27 | var d Vertex 28 | v := new(Vertex) 29 | d.X =8 30 | fmt.Println(v,d) 31 | v.X, v.Y = 11, 9 32 | fmt.Println(v) 33 | } 34 | ~~~ 35 | 36 | 输出: 37 | 38 | ~~~ 39 | &{0 0} {8 0} 40 | &{11 9} 41 | ~~~ -------------------------------------------------------------------------------- /builtin/nil.md: -------------------------------------------------------------------------------- 1 | ## var nil Type 2 | 3 | 功能说明: 4 | 5 | nil 是预定义用来表示pointer,channel,func,interface,map和slice类型的零值 6 | -------------------------------------------------------------------------------- /builtin/real.md: -------------------------------------------------------------------------------- 1 | ## func real(c ComplexType) FloatType 2 | 3 | 参数列表: 4 | 5 | - c ComplexType 复数 6 | 7 | 返回值: 8 | 9 | - FloatType 复数 c 的实部 10 | 11 | 功能说明: 12 | 13 | real 内建函数返回复数 c 的实部。 返回值类型与 c 的浮点类型对应。 14 | 15 | 代码实例: 16 | 17 | ```go 18 | package main 19 | 20 | import "fmt" 21 | 22 | func main() { 23 | fmt.Println(real(10 + 2i)) 24 | } 25 | ``` 26 | 27 | 输出: 28 | 29 | ~~~ 30 | 10 31 | ~~~ -------------------------------------------------------------------------------- /builtin/rune.md: -------------------------------------------------------------------------------- 1 | ## type rune rune 2 | 3 | 功能说明: 4 | 5 | rune 为 int32 的别名,它完全等价于 int32。 习惯上用它来区别字符值和整数值。 -------------------------------------------------------------------------------- /builtin/string.md: -------------------------------------------------------------------------------- 1 | ## type string string 2 | 3 | 功能说明: 4 | 5 | string 是所有8位字节的字符串集合,习惯上用于代表以UTF-8编码的文本,但并不必须如此。 string 可为空,但不为 nil。string 类型的值是不变的。 -------------------------------------------------------------------------------- /builtin/uint.md: -------------------------------------------------------------------------------- 1 | ## type uint uint 2 | 3 | 功能说明: 4 | 5 | uint 是无符号整数类型,其大小至少为32位。 它是一种确切的类型,而不是 uint32 的别名。 -------------------------------------------------------------------------------- /builtin/uint16.md: -------------------------------------------------------------------------------- 1 | ## type uint16 uint16 2 | 3 | 功能说明: 4 | 5 | uint16 是所有无符号16位整数的集合。 范围:0 至 65535。 -------------------------------------------------------------------------------- /builtin/uint32.md: -------------------------------------------------------------------------------- 1 | ## type uint32 uint32 2 | 3 | 功能说明: 4 | 5 | uint32 是所有无符号32位整数的集合。 范围:0 至 4294967295。 -------------------------------------------------------------------------------- /builtin/uint64.md: -------------------------------------------------------------------------------- 1 | ## type uint64 uint64 2 | 3 | 功能说明: 4 | 5 | uint64 是所有无符号64位整数的集合。 范围:0 至 18446744073709551615。 -------------------------------------------------------------------------------- /builtin/uint8.md: -------------------------------------------------------------------------------- 1 | ## type uint8 uint8 2 | 3 | 功能说明: 4 | 5 | uint8 是所有无符号8位整数的集合。 范围:0 至 255。 -------------------------------------------------------------------------------- /builtin/uintptr.md: -------------------------------------------------------------------------------- 1 | ## type uintptr uintptr 2 | 3 | 功能说明: 4 | 5 | uintptr 为整数类型,其大小足以容纳任何指针的位模式。 6 | -------------------------------------------------------------------------------- /bytes/Buffer_Len.md: -------------------------------------------------------------------------------- 1 | ## func (b *Buffer) Len() int 2 | 3 | 返回值 4 | 5 | - int 字节数 6 | 7 | 功能说明 8 | 9 | - 返回Buffer中未读数据的字节数。它满足条件b.Len() == len(b.Bytes())。 10 | 11 | 代码示例 12 | 13 | package main 14 | 15 | import ( 16 | "bytes" 17 | "fmt" 18 | ) 19 | 20 | func main() { 21 | b := bytes.NewBuffer([]byte("123456")) 22 | fmt.Println(b.Len()) 23 | var buff [3]byte 24 | b.Read(buff[:]) 25 | fmt.Println(b.Len()) 26 | } 27 | 28 | 代码输出 29 | 30 | 6 31 | 3 32 | -------------------------------------------------------------------------------- /bytes/Buffer_Next.md: -------------------------------------------------------------------------------- 1 | ## func (b *Buffer) Next(n int) []byte 2 | 3 | 参数列表 4 | 5 | - n 要读取的字节数 6 | 7 | 返回值 8 | 9 | - []byte 字节切片 10 | 11 | 功能说明 12 | 13 | - Next返回Buffer中下n个未读取的字节并返回,本次读取会修改Buffer中的读取位置。如果Buffer中未读数据不足n自己,则返回全部未读数据。返回的字节切片在下次读或者写前有效。 14 | 15 | 代码示例 16 | 17 | package main 18 | 19 | import ( 20 | "bytes" 21 | "fmt" 22 | ) 23 | 24 | func main() { 25 | b := bytes.NewBuffer([]byte("123456")) 26 | fmt.Println(string(b.Next(4))) 27 | fmt.Println(string(b.Next(4))) 28 | } 29 | 30 | 代码输出 31 | 32 | 1234 33 | 56 34 | -------------------------------------------------------------------------------- /bytes/Buffer_ReadByte.md: -------------------------------------------------------------------------------- 1 | ## func (b *Buffer) ReadByte() (c byte, err error) 2 | 3 | 返回值 4 | 5 | - c 读取的字节 6 | - err 错误 7 | 8 | 功能说明 9 | 10 | - ReadByte读取一个字节返回,如果没有数据可读则err为io.EOF。 11 | 12 | 代码示例 13 | 14 | package main 15 | 16 | import ( 17 | "bytes" 18 | "fmt" 19 | ) 20 | 21 | func main() { 22 | b := bytes.NewBuffer([]byte("123456")) 23 | c, err := b.ReadByte() 24 | fmt.Println(c, err) 25 | fmt.Println(string(b.Bytes())) 26 | } 27 | 28 | 代码输出 29 | 30 | 49 31 | 23456 32 | -------------------------------------------------------------------------------- /bytes/Buffer_Reset.md: -------------------------------------------------------------------------------- 1 | ## func (b *Buffer) Reset() 2 | 3 | 功能说明 4 | 5 | - Reset把Buffer中的数据清空,等同于b.Truncate(0)。 6 | 7 | 代码示例 8 | 9 | package main 10 | 11 | import ( 12 | "bytes" 13 | "fmt" 14 | ) 15 | 16 | func main() { 17 | b := bytes.NewBuffer([]byte("123")) 18 | fmt.Println(b.Len()) 19 | b.Reset() 20 | fmt.Println(b.Len()) 21 | } 22 | 23 | 代码输出 24 | 25 | 3 26 | 0 27 | -------------------------------------------------------------------------------- /bytes/Buffer_String.md: -------------------------------------------------------------------------------- 1 | ## func (b *Buffer) String() string 2 | 3 | 返回值 4 | 5 | - string 字符串 6 | 7 | 功能说明 8 | 9 | - String把Buffer中的未读数据作为string返回。如果Buffer是个nil指针,则返回 10 | 11 | 代码示例 12 | 13 | package main 14 | 15 | import ( 16 | "bytes" 17 | "fmt" 18 | ) 19 | 20 | func main() { 21 | var b *bytes.Buffer 22 | fmt.Println(b.String()) 23 | b = bytes.NewBuffer([]byte("123")) 24 | fmt.Println(b.String()) 25 | } 26 | 27 | 代码输出 28 | 29 | 30 | 123 31 | -------------------------------------------------------------------------------- /bytes/Buffer_Truncate.md: -------------------------------------------------------------------------------- 1 | ## func (b *Buffer) Truncate(n int) 2 | 3 | 参数列表 4 | 5 | - n 6 | 7 | 功能说明 8 | 9 | - Truncate只保留前n个字节的数据并清除其余数据。如果n < 0或者n > b.Len()则Truncate导致panic。n为0时,等同于b.Reset()。 10 | 11 | 代码示例 12 | 13 | package main 14 | 15 | import ( 16 | "bytes" 17 | "fmt" 18 | ) 19 | 20 | func main() { 21 | b := bytes.NewBuffer([]byte("123456")) 22 | b.Truncate(3) 23 | fmt.Println(b.String()) 24 | } 25 | 26 | 代码输出 27 | 28 | 123 29 | -------------------------------------------------------------------------------- /bytes/Buffer_UnreadByte.md: -------------------------------------------------------------------------------- 1 | ## func (b *Buffer) UnreadByte() error 2 | 3 | 返回值 4 | 5 | - err 错误 6 | 7 | 功能说明 8 | 9 | - UnreadByte取消上次读取的最后一个字节。如果上次读取之后有过写操作,则返回错误。 10 | 11 | 代码示例 12 | 13 | package main 14 | 15 | import ( 16 | "bytes" 17 | "fmt" 18 | ) 19 | 20 | func main() { 21 | b := bytes.NewBuffer([]byte("12345")) 22 | fmt.Println(string(b.Next(3))) 23 | b.UnreadByte() 24 | fmt.Println(b.String()) 25 | } 26 | 27 | 代码输出 28 | 29 | 123 30 | 345 31 | -------------------------------------------------------------------------------- /bytes/Buffer_Write.md: -------------------------------------------------------------------------------- 1 | ## func (b *Buffer) Write(p []byte) (n int, err error) 2 | 3 | 参数列表 4 | 5 | - p 要写入的字节切片 6 | 7 | 返回值 8 | 9 | - n 已写入的字节数 10 | - err 错误 11 | 12 | 功能说明 13 | 14 | - Write把p写入Buffer,返回的n满足n == len(p),err总是为nil。如果数据太大则Write会panic并产生ErrTooLarge异常。 15 | 16 | 代码示例 17 | 18 | package main 19 | 20 | import ( 21 | "bytes" 22 | "fmt" 23 | ) 24 | 25 | func main() { 26 | b := bytes.NewBuffer(nil) 27 | fmt.Println(b.Write([]byte("12345"))) 28 | fmt.Println(string(b.Bytes())) 29 | } 30 | 31 | 代码输出 32 | 33 | 5 34 | 12345 35 | -------------------------------------------------------------------------------- /bytes/Buffer_WriteByte.md: -------------------------------------------------------------------------------- 1 | ## func (b *Buffer) WriteByte(c byte) error 2 | 3 | 参数列表 4 | 5 | - c 要写入的字节 6 | 7 | 返回值 8 | 9 | - err 错误 10 | 11 | 功能说明 12 | 13 | - WriteByte写入一个字节,总是返回nil。这个返回值只是为了匹配bufio.Writer的Write函数。如果内部数据太大,WriteByte会panic并产生ErrTooLarge异常。 14 | 15 | 代码示例 16 | 17 | package main 18 | 19 | import ( 20 | "bytes" 21 | "fmt" 22 | ) 23 | 24 | func main() { 25 | b := bytes.NewBuffer(nil) 26 | b.WriteByte('1') 27 | b.WriteByte('2') 28 | b.WriteByte('3') 29 | fmt.Println(string(b.Bytes())) 30 | } 31 | 32 | 代码输出 33 | 34 | 123 35 | -------------------------------------------------------------------------------- /bytes/Buffer_WriteString.md: -------------------------------------------------------------------------------- 1 | ## func (b *Buffer) WriteString(s string) (n int, err error) 2 | 3 | 参数列表 4 | 5 | - s 要写入的字符串 6 | 7 | 返回值 8 | 9 | - n 写入的字节数 10 | - err 错误 11 | 12 | 功能说明 13 | 14 | - WriteString把s写入Buffer,返回值n为len(s),err总是为nil。如果内部缓冲区太大,WriteString会panic并产生ErrTooLarge异常。 15 | 16 | 代码示例 17 | 18 | package main 19 | 20 | import ( 21 | "bytes" 22 | "fmt" 23 | ) 24 | 25 | func main() { 26 | b := bytes.NewBuffer(nil) 27 | b.WriteString("你好世界") 28 | fmt.Println(string(b.Bytes())) 29 | } 30 | 31 | 代码输出 32 | 33 | 你好世界 34 | -------------------------------------------------------------------------------- /bytes/Contains.md: -------------------------------------------------------------------------------- 1 | ## func Contains(b, subslice []byte) bool 2 | 3 | 参数列表 4 | 5 | - b 字节切片 6 | - subslice 子字节切片 7 | 8 | 返回值 9 | 10 | - bool 是否包含子切片 11 | 12 | 功能说明 13 | 14 | - Contains检查字节切片b是否包含子字节切片subslice 15 | 16 | 代码示例 17 | 18 | package main 19 | 20 | import ( 21 | "bytes" 22 | "fmt" 23 | ) 24 | 25 | func main() { 26 | b := []byte("12345678") 27 | s1 := []byte("456") 28 | s2 := []byte("789") 29 | fmt.Println(bytes.Contains(b, s1)) 30 | fmt.Println(bytes.Contains(b, s2)) 31 | } 32 | 33 | 代码输出 34 | 35 | true 36 | false 37 | 38 | 39 | -------------------------------------------------------------------------------- /bytes/Count.md: -------------------------------------------------------------------------------- 1 | ## func Count(s, sep []byte) int 2 | 3 | 参数列表 4 | 5 | - s 字节切片 6 | - sep 子字节切片 7 | 8 | 返回值 9 | 10 | - int 子字节切片sep的数量 11 | 12 | 功能说明 13 | 14 | - Count计算子字节切片sep在字节切片s中非重叠实例的数量 15 | 16 | 代码示例 17 | 18 | package main 19 | 20 | import ( 21 | "bytes" 22 | "fmt" 23 | ) 24 | 25 | func main() { 26 | s := []byte("1234567777777") 27 | fmt.Println(bytes.Count(s, []byte("123"))) 28 | fmt.Println(bytes.Count(s, []byte("77"))) 29 | fmt.Println(bytes.Count(s, []byte("777"))) 30 | } 31 | 32 | 33 | 代码输出 34 | 35 | 1 36 | 3 37 | 2 38 | -------------------------------------------------------------------------------- /bytes/Index.md: -------------------------------------------------------------------------------- 1 | ## func Index(s, sep []byte) int 2 | 3 | 参数列表 4 | 5 | - s 要检查的字节切片 6 | - sep 子字节切片 7 | 8 | 返回值 9 | 10 | - int sep的位置索引(从0开始) 11 | 12 | 功能说明 13 | 14 | - Index返回sep在s中第一次出现的位置索引,如果sep不在s中则返回-1 15 | 16 | 代码示例 17 | 18 | package main 19 | 20 | import ( 21 | "bytes" 22 | "fmt" 23 | ) 24 | 25 | func main() { 26 | s := []byte("1234,12345678") 27 | fmt.Println(bytes.Index(s, []byte("34"))) 28 | fmt.Println(bytes.Index(s, []byte("789"))) 29 | } 30 | 31 | 代码输出 32 | 33 | 2 34 | -1 35 | -------------------------------------------------------------------------------- /bytes/IndexByte.md: -------------------------------------------------------------------------------- 1 | ## func IndexByte(s []byte, c byte) int 2 | 3 | 参数列表 4 | 5 | - s 字节切片 6 | - c 字节 7 | 8 | 返回值 9 | 10 | - int s中的位置索引(从0开始) 11 | 12 | 功能说明 13 | 14 | - IndexByte检查c在s中第一次出现的位置索引;如果s中不包含c则返回-1 15 | 16 | 代码示例 17 | 18 | package main 19 | 20 | import ( 21 | "bytes" 22 | "fmt" 23 | ) 24 | 25 | func main() { 26 | fmt.Println(bytes.IndexByte([]byte("1234"), '3')) 27 | } 28 | 29 | 代码输出 30 | 31 | 2 32 | -------------------------------------------------------------------------------- /bytes/IndexRune.md: -------------------------------------------------------------------------------- 1 | ## func IndexRune(s []byte, r rune) int 2 | 3 | 参数列表 4 | 5 | - s 字节切片 6 | - r Unicode字符 7 | 8 | 返回值 9 | 10 | - int s中的位置索引(从0开始) 11 | 12 | 功能说明 13 | 14 | - IndexRune把s解释为UTF-8字节序列,并返回r在s中的位置索引;如果s中不包含r则返回-1 15 | 16 | 代码示例 17 | 18 | package main 19 | 20 | import ( 21 | "bytes" 22 | "fmt" 23 | ) 24 | 25 | func main() { 26 | s := []byte("你好世界") 27 | index := bytes.IndexRune(s, '好') 28 | if index >= 0 { 29 | fmt.Println(index) 30 | fmt.Println(string(s[index:])) 31 | } 32 | } 33 | 34 | 代码输出 35 | 36 | 3 37 | 好世界 38 | 39 | -------------------------------------------------------------------------------- /bytes/LastIndex.md: -------------------------------------------------------------------------------- 1 | ## func LastIndex(s, sep []byte) int 2 | 3 | 参数列表 4 | 5 | - s 字节切片 6 | - sep 字节切片 7 | 8 | 返回值 9 | 10 | - int s中的位置索引(从0开始) 11 | 12 | 功能说明 13 | 14 | - LastIndex返回sep在s中最后一次出现的位置索引,如果s中不包含sep则返回-1。 15 | 16 | 代码示例 17 | 18 | package main 19 | 20 | import ( 21 | "bytes" 22 | "fmt" 23 | ) 24 | 25 | func main() { 26 | s := []byte("abcd,abcd") 27 | fmt.Println(bytes.LastIndex(s, []byte("abc"))) 28 | } 29 | 30 | 代码输出 31 | 32 | 5 33 | -------------------------------------------------------------------------------- /bytes/NewBuffer.md: -------------------------------------------------------------------------------- 1 | ## func NewBuffer(buf []byte) *Buffer 2 | 3 | 参数列表 4 | 5 | - buf 字节切片 6 | 7 | 返回值 8 | 9 | - *Buffer 10 | 11 | 功能说明 12 | 13 | - NewBuffer创建一个新的Buffer,并使用buf进行初始化。这个buf用来作为准备要读的数据;也可以用来指定写缓冲区的大小,这时buf应该是cap(buf)为指定大小,但是len(buf)为0。 14 | 15 | 代码示例 16 | 17 | package main 18 | 19 | import ( 20 | "bytes" 21 | "fmt" 22 | ) 23 | 24 | func main() { 25 | buf := []byte("123456") 26 | b := bytes.NewBuffer(buf) 27 | var data [6]byte 28 | b.Read(data[:]) 29 | fmt.Println(string(data[:])) 30 | } 31 | 32 | 代码输出 33 | 34 | 123456 35 | -------------------------------------------------------------------------------- /bytes/NewBufferString.md: -------------------------------------------------------------------------------- 1 | ## func NewBufferString(s string) *Buffer 2 | 3 | 参数列表 4 | 5 | - s 用于初始化Buffer内容的字符串 6 | 7 | 返回值 8 | 9 | - *Buffer 10 | 11 | 功能说明 12 | 13 | - NewBufferString创建一个Buffer,并用s初始化它的内容。它用于读已经存在的数据。大多数情况下,new(Buffer)或者直接声明一个Buffer变量就可以了。 14 | 15 | 代码示例 16 | 17 | package main 18 | 19 | import ( 20 | "bytes" 21 | "fmt" 22 | ) 23 | 24 | func main() { 25 | b := bytes.NewBufferString("123456") 26 | var data [6]byte 27 | b.Read(data[:]) 28 | fmt.Println(string(data[:])) 29 | } 30 | 31 | 代码输出 32 | 33 | 123456 34 | -------------------------------------------------------------------------------- /bytes/NewReader.md: -------------------------------------------------------------------------------- 1 | ## func NewReader(b []byte) *Reader 2 | 3 | 参数列表 4 | 5 | - b 字节切片 6 | 7 | 返回值 8 | 9 | - *Reader 10 | 11 | 功能说明 12 | 13 | - NewReader创建一个Reader,数据为b。 14 | 15 | 代码示例 16 | 17 | package main 18 | 19 | import ( 20 | "bytes" 21 | "fmt" 22 | ) 23 | 24 | func main() { 25 | b := bytes.NewReader([]byte("12345")) 26 | fmt.Println(b.Len()) 27 | } 28 | 29 | 代码输出 30 | 31 | 5 32 | -------------------------------------------------------------------------------- /bytes/Reader_Len.md: -------------------------------------------------------------------------------- 1 | ## func (r *Reader) Len() int 2 | 3 | 返回值 4 | 5 | - int Reader中未读数据的字节数 6 | 7 | 功能说明 8 | 9 | - Len返回Reader中未读数据的字节数 10 | 11 | 代码示例 12 | 13 | package main 14 | 15 | import ( 16 | "bytes" 17 | "fmt" 18 | ) 19 | 20 | func main() { 21 | b := bytes.NewReader([]byte("12345")) 22 | fmt.Println(b.Len()) 23 | } 24 | 25 | 代码输出 26 | 27 | 5 28 | -------------------------------------------------------------------------------- /bytes/Reader_ReadByte.md: -------------------------------------------------------------------------------- 1 | ## func (r *Reader) ReadByte() (b byte, err error) 2 | 3 | 返回值 4 | 5 | - b 读取的字节 6 | - err 错误 7 | 8 | 功能说明 9 | 10 | - ReadByte从Reader中读取一个字节并返回,如果遇到错误则返回错误(通常是io.EOF)。 11 | 12 | 代码示例 13 | 14 | package main 15 | 16 | import ( 17 | "bytes" 18 | "fmt" 19 | ) 20 | 21 | func main() { 22 | b := bytes.NewReader([]byte("12345")) 23 | c, err := b.ReadByte() 24 | fmt.Println(string(c), err) 25 | } 26 | 27 | 代码输出 28 | 29 | 1 30 | -------------------------------------------------------------------------------- /bytes/Reader_ReadRune.md: -------------------------------------------------------------------------------- 1 | ## func (r *Reader) ReadRune() (ch rune, size int, err error) 2 | 3 | 返回值 4 | 5 | - ch 读取的Unicode字符 6 | - size ch的UTF-8编码的字节数 7 | - err 错误 8 | 9 | 功能说明 10 | 11 | - ReadRune从Reader中按照UTF-8编码读取一个Unicode字符,返回此字符,其字符的UTF-8编码占用的字节数,如果遇到错误则返回错误(通常是io.EOF)。 12 | 13 | 代码示例 14 | 15 | package main 16 | 17 | import ( 18 | "bytes" 19 | "fmt" 20 | ) 21 | 22 | func main() { 23 | b := bytes.NewReader([]byte("你好世界")) 24 | r, size, err := b.ReadRune() 25 | fmt.Println(string(r), size, err) 26 | } 27 | 28 | 代码输出 29 | 30 | 你 3 31 | -------------------------------------------------------------------------------- /bytes/Repeat.md: -------------------------------------------------------------------------------- 1 | ## func Repeat(b []byte, count int) []byte 2 | 3 | 参数列表 4 | 5 | - b 字节切片 6 | - count 重复次数 7 | 8 | 返回值 9 | 10 | - []byte 新建的字节切片 11 | 12 | 功能说明 13 | 14 | - Repeat把b复制count次组合成一个新的字节切片并返回。 15 | 16 | 代码示例 17 | 18 | package main 19 | 20 | import ( 21 | "bytes" 22 | "fmt" 23 | ) 24 | 25 | func main() { 26 | b := []byte("123") 27 | fmt.Println(string(bytes.Repeat(b, 3))) 28 | } 29 | 30 | 代码输出 31 | 32 | 123123123 33 | -------------------------------------------------------------------------------- /bytes/Runes.md: -------------------------------------------------------------------------------- 1 | ## func Runes(s []byte) []rune 2 | 3 | 参数列表 4 | 5 | - s 字节切片 6 | 7 | 返回值 8 | 9 | - []rune s对应的Unicode字符切片 10 | 11 | 功能说明 12 | 13 | - Runes把s解释为UTF-8编码的字节序列,并返回对应的Unicode切片。 14 | 15 | 代码示例 16 | 17 | package main 18 | 19 | import ( 20 | "bytes" 21 | "fmt" 22 | ) 23 | 24 | func main() { 25 | s := []byte("你好世界") 26 | fmt.Printf("%d, %s\n", len(s), string(s)) 27 | r := bytes.Runes(s) 28 | fmt.Printf("%d, %s\n", len(r), string(r)) 29 | } 30 | 31 | 代码输出 32 | 33 | 12, 你好世界 34 | 4, 你好世界 35 | -------------------------------------------------------------------------------- /bytes/Title.md: -------------------------------------------------------------------------------- 1 | ## func Title(s []byte) []byte 2 | 3 | 参数列表 4 | 5 | - s 字节切片 6 | 7 | 返回值 8 | 9 | - []byte 被转换为首字母大写的字节切片 10 | 11 | 功能说明 12 | 13 | - Title返回s的一个副本,把s中每个单词的首字母改为Unicode字符的大写。 14 | 15 | 代码示例 16 | 17 | package main 18 | 19 | import ( 20 | "bytes" 21 | "fmt" 22 | ) 23 | 24 | func main() { 25 | s := []byte("hello, world!") 26 | fmt.Println(string(bytes.Title(s))) 27 | fmt.Println(string(s)) 28 | } 29 | 30 | 代码输出 31 | 32 | Hello, World! 33 | hello, world! 34 | -------------------------------------------------------------------------------- /bytes/ToLower.md: -------------------------------------------------------------------------------- 1 | ## func ToLower(s []byte) []byte 2 | 3 | 参数列表 4 | 5 | - s 字节切片 6 | 7 | 返回值 8 | 9 | - []byte 被转换为字符小写的字节切片 10 | 11 | 功能说明 12 | 13 | - ToLower返回s的一个副本,并把其中所有的Unicode字符转换为小写。 14 | 15 | 代码示例 16 | 17 | package main 18 | 19 | import ( 20 | "bytes" 21 | "fmt" 22 | ) 23 | 24 | func main() { 25 | s := []byte("Hello, World!") 26 | fmt.Println(string(bytes.ToLower(s))) 27 | fmt.Println(string(s)) 28 | } 29 | 30 | 代码输出 31 | 32 | hello, world! 33 | Hello, World! 34 | 35 | -------------------------------------------------------------------------------- /bytes/ToUpper.md: -------------------------------------------------------------------------------- 1 | ## func ToUpper(s []byte) []byte 2 | 3 | 参数列表 4 | 5 | - s 字节切片 6 | 7 | 返回值 8 | 9 | - []byte 被转换为字符大写的字节切片 10 | 11 | 功能说明 12 | 13 | - ToUpper返回s的一个副本,并把其中所有的Unicode字符转换为大写。 14 | 15 | 代码示例 16 | 17 | package main 18 | 19 | import ( 20 | "bytes" 21 | "fmt" 22 | ) 23 | 24 | func main() { 25 | s := []byte("hello, world!") 26 | fmt.Println(string(bytes.ToUpper(s))) 27 | fmt.Println(string(s)) 28 | } 29 | 30 | 代码输出 31 | 32 | HELLO, WORLD! 33 | hello, world! 34 | 35 | -------------------------------------------------------------------------------- /bytes/Trim.md: -------------------------------------------------------------------------------- 1 | ## func Trim(s []byte, cutset string) []byte 2 | 3 | 参数列表 4 | 5 | - s 字节切片 6 | - cutset 字符串 7 | 8 | 返回值 9 | 10 | - []byte s的子字节切片 11 | 12 | 功能说明 13 | 14 | - Trim返回s的子字节切片,不包含s首部和尾部的连续的cutset中的任意字符。 15 | 16 | 代码示例 17 | 18 | package main 19 | 20 | import ( 21 | "bytes" 22 | "fmt" 23 | ) 24 | 25 | func main() { 26 | s := []byte("123456789") 27 | fmt.Println(string(bytes.Trim(s, "1389"))) 28 | } 29 | 30 | 代码输出 31 | 32 | 234567 33 | -------------------------------------------------------------------------------- /bytes/TrimFunc.md: -------------------------------------------------------------------------------- 1 | ## func TrimFunc(s []byte, f func(r rune) bool) []byte 2 | 3 | 参数列表 4 | 5 | - s 字节切片 6 | - f 检查函数 7 | 8 | 返回值 9 | 10 | - []byte s的子字节切片 11 | 12 | 功能说明 13 | 14 | - TrimFunc返回s的子字节切片,不包含s首部和尾部连接的满足f(c)==true的字符c。 15 | 16 | 代码示例 17 | 18 | package main 19 | 20 | import ( 21 | "bytes" 22 | "fmt" 23 | ) 24 | 25 | func main() { 26 | s := []byte("12345678") 27 | f := func(r rune) bool { 28 | return r <= '3' || r >= '6' 29 | } 30 | fmt.Println(string(bytes.TrimFunc(s, f))) 31 | } 32 | 33 | 代码输出 34 | 35 | 45 36 | -------------------------------------------------------------------------------- /bytes/TrimLeft.md: -------------------------------------------------------------------------------- 1 | ## func TrimLeft(s []byte, cutset string) []byte 2 | 3 | 参数列表 4 | 5 | - s 字节切片 6 | - cutset 字符串 7 | 8 | 返回值 9 | 10 | - []byte s的子字节切片 11 | 12 | 功能说明 13 | 14 | - TrimLeft返回s的子字节切片,不包含s首部的连续的cutset中的任意字符。 15 | 16 | 代码示例 17 | 18 | package main 19 | 20 | import ( 21 | "bytes" 22 | "fmt" 23 | ) 24 | 25 | func main() { 26 | s := []byte("9812345") 27 | fmt.Println(string(bytes.TrimLeft(s, "129"))) 28 | } 29 | 30 | 代码输出 31 | 32 | 812345 33 | -------------------------------------------------------------------------------- /bytes/TrimLeftFunc.md: -------------------------------------------------------------------------------- 1 | ## func TrimLeftFunc(s []byte, f func(r rune) bool) []byte 2 | 3 | 参数列表 4 | 5 | - s 字节切片 6 | - f 检查函数 7 | 8 | 返回值 9 | 10 | - []byte s的子字节切片 11 | 12 | 功能说明 13 | 14 | - TrimLeftFunc返回s的一个子字节切片,不包含s首部连续满足f(c)==true的字符c。 15 | 16 | 代码示例 17 | 18 | package main 19 | 20 | import ( 21 | "bytes" 22 | "fmt" 23 | ) 24 | 25 | func main() { 26 | s := []byte("123456789") 27 | f := func(r rune) bool { 28 | return r < '4' 29 | } 30 | fmt.Println(string(bytes.TrimLeftFunc(s, f))) 31 | } 32 | 33 | 代码输出 34 | 35 | 456789 36 | -------------------------------------------------------------------------------- /bytes/TrimRight.md: -------------------------------------------------------------------------------- 1 | ## func TrimRight(s []byte, cutset string) []byte 2 | 3 | 参数列表 4 | 5 | - s 字节切片 6 | - cutset 字符串 7 | 8 | 返回值 9 | 10 | - []byte s的子字节切片 11 | 12 | 功能说明 13 | 14 | - TrimRight返回s的子字节切片,不包含s尾部的连续的cutset中的任意字符。 15 | 16 | 代码示例 17 | 18 | package main 19 | 20 | import ( 21 | "bytes" 22 | "fmt" 23 | ) 24 | 25 | func main() { 26 | s := []byte("98123456789") 27 | fmt.Println(string(bytes.TrimRight(s, "689"))) 28 | } 29 | 30 | 代码输出 31 | 32 | 981234567 33 | 34 | 35 | -------------------------------------------------------------------------------- /bytes/TrimRightFunc.md: -------------------------------------------------------------------------------- 1 | ## func TrimRightFunc(s []byte, f func(r rune) bool) []byte 2 | 3 | 参数列表 4 | 5 | - s 字节切片 6 | - f 检查函数 7 | 8 | 返回值 9 | 10 | - []byte s的子字节切片 11 | 12 | 功能说明 13 | 14 | - TrimRightFunc返回s的一个子字节切片,不包含s尾部连续满足f(c)==true的字符c。 15 | 16 | 代码示例 17 | 18 | package main 19 | 20 | import ( 21 | "bytes" 22 | "fmt" 23 | ) 24 | 25 | func main() { 26 | s := []byte("123456789") 27 | f := func(r rune) bool { 28 | return r > '7' 29 | } 30 | fmt.Println(string(bytes.TrimRightFunc(s, f))) 31 | } 32 | 33 | 代码输出 34 | 35 | 1234567 36 | -------------------------------------------------------------------------------- /compress/README.md: -------------------------------------------------------------------------------- 1 | # compress 2 | 3 | 二级包列表 4 | 5 | - [compress/bzip2](bzip2) 6 | - [compress/flate](flate) 7 | - [compress/gzip](gzip) 8 | - [compress/lzw](lzw) 9 | - [compress/zlib](zlib) -------------------------------------------------------------------------------- /compress/bzip2/README.md: -------------------------------------------------------------------------------- 1 | # 包名 compress/bzip2 2 | 3 | 函数列表 4 | 5 | - [func NewReader(r io.Reader) io.Reader](NewReader.md) 6 | - [func (s StructuralError) Error() string](StructuralError.Error.md) -------------------------------------------------------------------------------- /compress/flate/CorruptInputError.Error.md: -------------------------------------------------------------------------------- 1 | # func (e CorruptInputError) Error() string 2 | 3 | 返回值:在输入的指定偏移量位置存在损坏的错误信息 4 | 5 | 功能说明:CorruptInputError其实是一个int64,他实现了error接口,用于很方便的返回输入的指定偏移量位置存在损坏的错误信息 6 | 7 | 示例: 8 | 9 | 可能是一些读取、写入、拷贝等函数返回的error信息,这里不再举例。 -------------------------------------------------------------------------------- /compress/flate/InternalError.Error.md: -------------------------------------------------------------------------------- 1 | # func (e InternalError) Error() string 2 | 3 | 返回值:表示flate数据自身的错误信息 4 | 5 | 功能说明:InternalError其实是一个string,他实现了error接口,用于很方便的返回flate数据自身的错误信息 6 | 7 | 示例: 8 | 9 | 函数返回的error信息,这里不再举例。 -------------------------------------------------------------------------------- /compress/flate/ReadError.Error.md: -------------------------------------------------------------------------------- 1 | # func (e *ReadError) Error() string 2 | 3 | 返回值:表示flate读取拷贝数据时的错误信息 4 | 5 | 功能说明:ReadError其实是一个struct,他实现了error接口,用于很方便的返回flate读取拷贝数据时的错误信息 6 | 7 | 示例: 8 | 9 | flate读取拷贝数据时的错误信息,这里不再举例。 -------------------------------------------------------------------------------- /compress/flate/WriteError.Error.md: -------------------------------------------------------------------------------- 1 | # func (e *WriteError) Error() string 2 | 3 | 返回值:表示flate输出数据的错误信息 4 | 5 | 功能说明:WriteError是一个struct,他实现了error接口,用于很方便的返回flate输出数据的错误信息 6 | 7 | 示例: 8 | 9 | 返回输出数据的错误信息,这里不再举例。 -------------------------------------------------------------------------------- /compress/lzw/README.md: -------------------------------------------------------------------------------- 1 | # 包名 compress/lzw 2 | 3 | 函数列表 4 | 5 | - [func NewReader(r io.Reader, order Order, litWidth int) io.ReadCloser](NewReader.md) 6 | - [func NewWriter(w io.Writer, order Order, litWidth int) io.WriteCloser](NewWriter.md) -------------------------------------------------------------------------------- /compress/zlib/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /container/README.md: -------------------------------------------------------------------------------- 1 | # container 2 | 3 | ## 概述 4 | 常用的容器工具包,目前有heap、list、ring三种数据结构 5 | 6 | ## 子包列表 7 | 8 | - heap 堆(可实现最大堆和最小堆) 9 | - list 双向链表 10 | - ring 环形链表 11 | 12 | 13 | -------------------------------------------------------------------------------- /container/heap/README.md: -------------------------------------------------------------------------------- 1 | # heap包 2 | 3 | ## 概述: 4 | 5 | 任何实现了`heap.Interface`接口的对象都可以使用heap包提供的方法对堆进行操作(堆是一个完全二叉树)。通过对`heap.Interface`中的`Less`方法的不同实现,来实现最大堆和最小堆。通常堆的数据结构为一个一维数组。 6 | 7 | 维基百科:[堆(数据结构)](http://zh.wikipedia.org/wiki/%E5%A0%86_(%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84\)) 8 | 9 | ## 函数列表: 10 | 11 | - [func Init(h Interface)](Init.md) 12 | - [func Pop(h Interface) interface{}](Pop.md) 13 | - [func Push(h Interface, x interface{})](Push.md) 14 | - [func Remove(h Interface, i int) interface{}](Remove.md) 15 | - [type Interface](Interface.md) 16 | -------------------------------------------------------------------------------- /container/list/Back.md: -------------------------------------------------------------------------------- 1 | # func (l *List) Back() *Element 2 | 3 | 返回值: 4 | 5 | - `*Element`:链表中最后一个节点的指针,如果链表长度为0,则为`nil` 6 | 7 | 功能说明: 8 | 9 | 获得最后一个节点的指针,如果链表长度为0,则为`nil` 10 | 11 | 代码实例: 12 | 13 | ```go 14 | 15 | package main 16 | 17 | import ( 18 | "container/list" 19 | "fmt" 20 | ) 21 | 22 | func main() { 23 | l := list.New() 24 | e := l.Back() 25 | fmt.Println(e == nil) 26 | l.PushBack("a") 27 | e = l.Back() 28 | fmt.Println(e.Value) // 输出:a 29 | } 30 | 31 | ``` -------------------------------------------------------------------------------- /container/list/Front.md: -------------------------------------------------------------------------------- 1 | # func (l *List) Front() *Element 2 | 3 | 返回值: 4 | 5 | - `*Element`:链表中第一个节点的指针,如果链表长度为0,则为`nil` 6 | 7 | 功能说明: 8 | 9 | 获得第一个节点的指针,如果链表长度为0,则为`nil` 10 | 11 | 代码实例: 12 | 13 | ```go 14 | 15 | package main 16 | 17 | import ( 18 | "container/list" 19 | "fmt" 20 | ) 21 | 22 | func main() { 23 | l := list.New() 24 | e := l.Front() 25 | fmt.Println(e == nil) 26 | l.PushFront("b") 27 | e = l.Front() 28 | fmt.Println(e.Value) // 输出:b 29 | } 30 | 31 | ``` -------------------------------------------------------------------------------- /container/list/Init.md: -------------------------------------------------------------------------------- 1 | # func (l *List) Init() *List 2 | 3 | 返回值: 4 | 5 | - `*List`:初始化或者清空后的链表 6 | 7 | 功能说明: 8 | 9 | 初始化或者清空链表,该方法调用后,链表的长度为0 10 | 11 | 代码实例: 12 | 13 | ```go 14 | 15 | package main 16 | 17 | import ( 18 | "container/list" 19 | "fmt" 20 | ) 21 | 22 | func main() { 23 | l := list.New() 24 | l.PushBack("a") 25 | l.PushBack("b") 26 | l.PushBack("c") 27 | fmt.Println(l.Len()) // 输出:3 28 | 29 | l.Init() 30 | fmt.Println(l.Len()) // 输出:0 31 | } 32 | 33 | ``` -------------------------------------------------------------------------------- /container/list/List.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astaxie/gopkg/ac1fbcc823ecf390730a2a9665cad913643a23aa/container/list/List.md -------------------------------------------------------------------------------- /container/list/New.md: -------------------------------------------------------------------------------- 1 | # func New() *List 2 | 3 | 返回值: 4 | 5 | - `*List`:空链表的指针 6 | 7 | 功能说明: 8 | 9 | 创建一个空链表,链表的长度为0,开头和末尾节点都是`nil` 10 | 11 | 代码实例: 12 | 13 | ```go 14 | 15 | package main 16 | 17 | import ( 18 | "container/list" 19 | "fmt" 20 | ) 21 | 22 | func main() { 23 | l := list.New() 24 | e := l.Front() // 取出链表开头的节点,即节点a 25 | fmt.Println(e == nil) // 输出:true 26 | } 27 | 28 | ``` -------------------------------------------------------------------------------- /container/list/Remove.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astaxie/gopkg/ac1fbcc823ecf390730a2a9665cad913643a23aa/container/list/Remove.md -------------------------------------------------------------------------------- /container/ring/Do.md: -------------------------------------------------------------------------------- 1 | # func (r *Ring) Do(f func(interface{})) 2 | 3 | 参数列表: 4 | 5 | - `f`:一个回调函数,该函数的参数为环形双向链表中的节点的`Value`字段值 6 | 7 | 功能说明: 8 | 9 | 正向遍历环形双向链表,并对每个链表中的元素执行回调函数`f`,如果这个回调函数`f`会修改链表`r`,那这个回调函数的行为将不可确定 10 | 11 | 代码实例: 12 | 13 | ```go 14 | 15 | package main 16 | 17 | import ( 18 | "container/ring" 19 | "fmt" 20 | ) 21 | 22 | func main() { 23 | r := ring.New(10) 24 | n := 0 25 | r.Do(func(v interface{}){ 26 | n++ 27 | v = n 28 | fmt.Printf("%d ", v) // 输出:1 2 3 4 5 6 7 8 9 10 29 | }) 30 | } 31 | 32 | ``` -------------------------------------------------------------------------------- /container/ring/Len.md: -------------------------------------------------------------------------------- 1 | # func (r *Ring) Len() int 2 | 3 | 返回值: 4 | 5 | - `int`:环形链表中元素的个数 6 | 7 | 功能说明: 8 | 9 | 遍历环形双向链表来统计链表中的元素的个数 10 | 11 | 代码实例: 12 | 13 | ```go 14 | 15 | package main 16 | 17 | import ( 18 | "container/ring" 19 | "fmt" 20 | ) 21 | 22 | func main() { 23 | r := ring.New(10) 24 | fmt.Println(r.Len() == 10) // 输出:true 25 | } 26 | 27 | ``` -------------------------------------------------------------------------------- /container/ring/New.md: -------------------------------------------------------------------------------- 1 | # func New(n int) *Ring 2 | 3 | 参数列表: 4 | 5 | - `n`:环形双向链表的节点的个数 6 | 7 | 返回值: 8 | 9 | - `*Ring`:空链表的指针 10 | 11 | 功能说明: 12 | 13 | 创建一个有n个节点的环形双向链表 14 | 15 | 代码实例: 16 | 17 | ```go 18 | 19 | package main 20 | 21 | import ( 22 | "container/ring" 23 | "fmt" 24 | ) 25 | 26 | func main() { 27 | r := ring.New(10) 28 | fmt.Println(r.Len() == 10) // 输出:true 29 | } 30 | 31 | ``` -------------------------------------------------------------------------------- /container/ring/README.md: -------------------------------------------------------------------------------- 1 | # ring包 2 | 3 | ## 概述: 4 | 5 | ring包实现了环形双向链表的功能。 6 | 7 | ## 函数列表: 8 | 9 | - [type Ring](Ring.md) 10 | - [func New(n int) *Ring](New.md) 11 | - [func (r *Ring) Do(f func(interface{}))](Do.md) 12 | - [func (r *Ring) Len() int](Len.md) 13 | - [func (r *Ring) Link(s *Ring) *Ring](Link.md) 14 | - [func (r *Ring) Move(n int) *Ring](Move.md) 15 | - [func (r *Ring) Next() *Ring](Next.md) 16 | - [func (r *Ring) Prev() *Ring](Prev.md) 17 | - [func (r *Ring) Unlink(n int) *Ring](Unlink.md) 18 | -------------------------------------------------------------------------------- /crypto/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /crypto/aes/Constants.md: -------------------------------------------------------------------------------- 1 | ## const BlockSize = 16 2 | 3 | 功能说明: 4 | 5 | The AES block size in bytes. 6 | AES算法的块(加密数据块)的字节长度。 7 | 8 | 具体使用参见[func NewCipher(key []byte) (cipher.Block, error)](NewCipher.md) 9 | -------------------------------------------------------------------------------- /crypto/aes/KeySizeError.md: -------------------------------------------------------------------------------- 1 | ## type KeySizeError int 2 | 3 | 功能说明: 4 | 5 | 密钥长度错误的类型定义。 6 | 7 | 具体使用参见[func (k KeySizeError) Error() string](KeySizeError.Error.md) 8 | -------------------------------------------------------------------------------- /crypto/aes/README.md: -------------------------------------------------------------------------------- 1 | # crypto/aes包函数列表 2 | 3 | - [Constants](Constants.md) 4 | - [func NewCipher(key []byte) (cipher.Block, error)](NewCipher.md) 5 | - [type KeySizeError](KeySizeError.md) 6 | - [func (k KeySizeError) Error() string](KeySizeError.Error.md) -------------------------------------------------------------------------------- /crypto/cipher/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /crypto/des/Constants.md: -------------------------------------------------------------------------------- 1 | ## const BlockSize = 8 2 | 3 | 功能说明: 4 | 5 | The DES block size in bytes. 6 | DES算法的块(加密数据块)的字节长度。 7 | 8 | 具体使用参见[func NewCipher(key []byte) (cipher.Block, error)](NewCipher.md) 9 | -------------------------------------------------------------------------------- /crypto/des/KeySizeError.md: -------------------------------------------------------------------------------- 1 | ## type KeySizeError int 2 | 3 | 功能说明: 4 | 5 | 密钥长度错误的类型定义。 6 | 7 | 具体使用参见[func (k KeySizeError) Error() string](KeySizeError.Error.md) 8 | -------------------------------------------------------------------------------- /crypto/des/README.md: -------------------------------------------------------------------------------- 1 | # crypto/des包函数列表 2 | 3 | - [Constants](Constants.md) 4 | - [func NewCipher(key []byte) (cipher.Block, error)](NewCipher.md) 5 | - [func NewTripleDESCipher(key []byte) (cipher.Block, error)](NewTripleDESCipher.md) 6 | - [type KeySizeError](KeySizeError.md) 7 | - [func (k KeySizeError) Error() string](KeySizeError.Error.md) -------------------------------------------------------------------------------- /crypto/dsa/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /crypto/ecdsa/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /crypto/elliptic/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /crypto/hmac/README.md: -------------------------------------------------------------------------------- 1 | # crypto/hmac包函数列表 2 | 3 | - [func New(h func() hash.Hash, key []byte) hash.Hash](New.md) -------------------------------------------------------------------------------- /crypto/md5/Constants.md: -------------------------------------------------------------------------------- 1 | ## const BlockSize = 64 2 | 3 | 功能说明: 4 | 5 | The blocksize of MD5 in bytes. 6 | MD5的数据块的字节长度为64字节。 7 | 8 | ## const Size = 16 9 | 10 | 功能说明: 11 | 12 | The size of an MD5 checksum in bytes. 13 | MD5的校验和的字节长度为16字节。 14 | 15 | 具体使用参见[func New() hash.Hash](New.md) -------------------------------------------------------------------------------- /crypto/md5/README.md: -------------------------------------------------------------------------------- 1 | # crypto/md5包函数列表 2 | 3 | - [Constants](Constants.md) 4 | - [func New() hash.Hash](New.md) -------------------------------------------------------------------------------- /crypto/rand/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /crypto/rc4/Cipher.md: -------------------------------------------------------------------------------- 1 | ## type Cipher 2 | 3 | type Cipher struct { 4 | // contains filtered or unexported fields 5 | } 6 | 7 | 功能说明: 8 | 9 | RC4加密算法需要的Cipher的结构定义。 10 | 具体使用参见[func NewCipher(key []byte) (*Cipher, error)](NewCipher.md) -------------------------------------------------------------------------------- /crypto/rc4/KeySizeError.md: -------------------------------------------------------------------------------- 1 | ## type KeySizeError int 2 | 3 | 功能说明: 4 | 5 | 密钥长度错误的类型定义。 6 | 7 | 具体使用参见[func (k KeySizeError) Error() string](KeySizeError.Error.md) 8 | -------------------------------------------------------------------------------- /crypto/rc4/README.md: -------------------------------------------------------------------------------- 1 | # crypto/rc4包函数列表 2 | 3 | - [type Cipher](Cipher.md) 4 | - [func NewCipher(key []byte) (*Cipher, error)](NewCipher.md) 5 | - [func (c *Cipher) Reset()](Reset.md) 6 | - [func (c *Cipher) XORKeyStream(dst, src []byte)](XORKeyStream.md) 7 | - [type KeySizeError](KeySizeError.md) 8 | - [func (k KeySizeError) Error() string](KeySizeError.Error.md) 9 | - [Bugs](Bugs.md) -------------------------------------------------------------------------------- /crypto/rc4/XORKeyStream.md: -------------------------------------------------------------------------------- 1 | ## func (c *Cipher) XORKeyStream(dst, src []byte) 2 | 3 | 参数列表 4 | 5 | - dst 目标 6 | - src 源 7 | 8 | 返回值: 9 | 10 | - 无 11 | 12 | 功能说明: 13 | 14 | XORKeyStream sets dst to the result of XORing src with the key stream. Dst and src may be the same slice but otherwise should not overlap. 15 | XORKeyStream方法设置dst为src与密钥流的xor(异或)运算结果。dst和src应该是同一的slice但不应重叠。 16 | 17 | 代码实例: 18 | 19 | 具体使用参见[func NewCipher(key []byte) (*Cipher, error)](NewCipher.md) 20 | -------------------------------------------------------------------------------- /crypto/rsa/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /crypto/sha1/Constants.md: -------------------------------------------------------------------------------- 1 | ## const BlockSize = 64 2 | 3 | 功能说明: 4 | 5 | The blocksize of MD5 in bytes. 6 | SHA1的数据块的字节长度为64字节。 7 | 8 | ## const Size = 20 9 | 10 | 功能说明: 11 | 12 | The size of an MD5 checksum in bytes. 13 | SHA1的校验和的字节长度为20字节。 14 | 15 | 具体使用参见[func New() hash.Hash](New.md) -------------------------------------------------------------------------------- /crypto/sha1/README.md: -------------------------------------------------------------------------------- 1 | # crypto/sha1包函数列表 2 | 3 | - [Constants](Constants.md) 4 | - [func New() hash.Hash](New.md) -------------------------------------------------------------------------------- /crypto/sha256/README.md: -------------------------------------------------------------------------------- 1 | # crypto/sha256包函数列表 2 | 3 | - [func New() hash.Hash](New.md) 4 | - [func New224() hash.Hash](New224.md) -------------------------------------------------------------------------------- /crypto/sha512/README.md: -------------------------------------------------------------------------------- 1 | # crypto/sha512包函数列表 2 | 3 | - [func New() hash.Hash](New.md) 4 | - [func New384() hash.Hash](New384.md) -------------------------------------------------------------------------------- /crypto/tls/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /crypto/x509/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /crypto/x509/pkix/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /database/README.md: -------------------------------------------------------------------------------- 1 | # database 包名 2 | 3 | database包主要是数据库的接口定义,下面有子包sql 4 | 5 | - [sql](sql/README.md) -------------------------------------------------------------------------------- /debug/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /debug/dwarf/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /debug/elf/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /debug/gosym/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /debug/macho/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /debug/pe/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /encoding/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /encoding/ascii85/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /encoding/asn1/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /encoding/base32/examples/CorruptInputError.mdpp: -------------------------------------------------------------------------------- 1 | ## func (e CorruptInputError) Error() string 2 | 3 | 参数列表: 4 | 5 | 无 6 | 7 | 返回值: 8 | 9 | - 错误描述 10 | 11 | 功能说明: 12 | 13 | 返回错误描述 14 | 15 | 代码实例: 16 | 17 | ```go 18 | !INCLUDE "CorruptInputError_test.go" 19 | ``` 20 | -------------------------------------------------------------------------------- /encoding/base32/examples/Decode.mdpp: -------------------------------------------------------------------------------- 1 | ## func (enc *Encoding) Decode(dst, src []byte) (n int, err error) 2 | 3 | 参数列表: 4 | 5 | - dst 解码缓冲区 6 | - src 要解码的字符串切片 7 | 8 | 返回值: 9 | 10 | - n 解码到缓冲区的字节数 11 | - err 可能的错误 12 | 13 | 功能说明: 14 | 15 | 对输入的字符串进行 base32 解码 16 | 17 | 代码实例: 18 | 19 | ```go 20 | !INCLUDE "Decode_test.go" 21 | ``` 22 | -------------------------------------------------------------------------------- /encoding/base32/examples/DecodeString.mdpp: -------------------------------------------------------------------------------- 1 | ## func (enc *Encoding) DecodeString(s string) ([]byte, error) 2 | 3 | 参数列表: 4 | 5 | - s 要进行 base32 解码的字符串 6 | 7 | 返回值: 8 | 9 | - 经过 base32 解码后的字符串切片 10 | - 可能的错误 11 | 12 | 功能说明: 13 | 14 | 对传入的字符串进行 base323 解码 15 | 16 | 代码实例: 17 | 18 | ```go 19 | !INCLUDE "DecodeString_test.go" 20 | ``` 21 | -------------------------------------------------------------------------------- /encoding/base32/examples/DecodedLen.mdpp: -------------------------------------------------------------------------------- 1 | ## func (enc *Encoding) DecodedLen(n int) int 2 | 3 | 参数列表: 4 | 5 | - n 要进行 base32 解码的字节数 6 | 7 | 返回值: 8 | 9 | - base32 解码输出需要的最大字节数 10 | 11 | 功能说明: 12 | 13 | 计算 base32 解码输出需要的最大字节数 14 | 15 | 代码实例: 16 | 17 | ```go 18 | !INCLUDE "DecodedLen_test.go" 19 | ``` 20 | -------------------------------------------------------------------------------- /encoding/base32/examples/DecodedLen_test.go: -------------------------------------------------------------------------------- 1 | package examples 2 | 3 | import ( 4 | "fmt" 5 | "encoding/base32" 6 | ) 7 | 8 | func ExampleDecodedLen1() { 9 | 10 | src := "ORUGS4ZANFZSAYJAORSXG5BAON2HE2LOM4XA====" 11 | 12 | // 解码需要的缓冲区的最大长度 13 | l := base32.StdEncoding.DecodedLen(len(src)) 14 | 15 | dst, _ := base32.StdEncoding.DecodeString(src) 16 | fmt.Println(len(dst) <= l) 17 | 18 | // Output: 19 | // true 20 | } 21 | -------------------------------------------------------------------------------- /encoding/base32/examples/Encode.mdpp: -------------------------------------------------------------------------------- 1 | ## func (enc *Encoding) Encode(dst, src []byte) 2 | 3 | 参数列表: 4 | 5 | - dst 编码缓冲区 6 | - src 要编码的字符串切片 7 | 8 | 返回值: 9 | 10 | 无 11 | 12 | 功能说明: 13 | 14 | 对输入的字符串进行 base32 编码 15 | 16 | 代码实例: 17 | 18 | ```go 19 | !INCLUDE "Encode_test.go" 20 | ``` 21 | -------------------------------------------------------------------------------- /encoding/base32/examples/EncodeToString.mdpp: -------------------------------------------------------------------------------- 1 | ## func (enc *Encoding) EncodeToString(src []byte) string 2 | 3 | 参数列表: 4 | 5 | - src 要进行 base32 编码的字符串切片 6 | 7 | 返回值: 8 | 9 | - 经过 base32 编码后的字符串 10 | 11 | 功能说明: 12 | 13 | 对传入的字符串切片进行 base32 编码 14 | 15 | 代码实例: 16 | 17 | ```go 18 | !INCLUDE "EncodeToString_test.go" 19 | ``` 20 | -------------------------------------------------------------------------------- /encoding/base32/examples/EncodedLen.mdpp: -------------------------------------------------------------------------------- 1 | ## func (enc *Encoding) EncodedLen(n int) int 2 | 3 | 参数列表: 4 | 5 | - n 要进行 base32 编码的字节数 6 | 7 | 返回值: 8 | 9 | - 经过 base32 编码后的字节数 10 | 11 | 功能说明: 12 | 13 | 计算编码输出的字节数 14 | 15 | 代码实例: 16 | 17 | ```go 18 | !INCLUDE "EncodedLen_test.go" 19 | ``` 20 | -------------------------------------------------------------------------------- /encoding/base32/examples/EncodedLen_test.go: -------------------------------------------------------------------------------- 1 | package examples 2 | 3 | import ( 4 | "fmt" 5 | "encoding/base32" 6 | ) 7 | 8 | func ExampleEncodedLen1() { 9 | 10 | src := []byte("this is a test string.") 11 | 12 | // 编码需要的缓冲区长度 13 | l := base32.StdEncoding.EncodedLen(len(src)) 14 | 15 | dst := base32.StdEncoding.EncodeToString(src) 16 | fmt.Println(len(dst) == l) 17 | 18 | // Output: 19 | // true 20 | } 21 | -------------------------------------------------------------------------------- /encoding/base32/examples/NewDecoder.mdpp: -------------------------------------------------------------------------------- 1 | ## func NewDecoder(enc *Encoding, r io.Reader) io.Reader 2 | 3 | 参数列表: 4 | 5 | - enc Encoding 结构指针 6 | - w io.Reader 接口 7 | 8 | 返回值: 9 | 10 | - io.Reader 接口 11 | 12 | 功能说明: 13 | 14 | 返回一个 io.Reader 接口,用于流式解码 15 | 16 | 代码实例: 17 | 18 | ```go 19 | !INCLUDE "NewDecoder_test.go" 20 | ``` 21 | -------------------------------------------------------------------------------- /encoding/base32/examples/NewEncoder.mdpp: -------------------------------------------------------------------------------- 1 | ## func NewEncoder(enc *Encoding, w io.Writer) io.WriteCloser 2 | 3 | 参数列表: 4 | 5 | - enc Encoding 结构指针 6 | - w io.Writer 接口 7 | 8 | 返回值: 9 | 10 | - io.WriteCloser 接口 11 | 12 | 功能说明: 13 | 14 | 返回一个 io.WriteCloser 接口,用于流式编码 15 | 16 | 代码实例: 17 | 18 | ```go 19 | !INCLUDE "NewEncoder_test.go" 20 | ``` 21 | -------------------------------------------------------------------------------- /encoding/base32/examples/NewEncoding.mdpp: -------------------------------------------------------------------------------- 1 | ## func NewEncoding(encoder string) *Encoding 2 | 3 | 参数列表: 4 | 5 | - encoder 32字节长的字符串,用做转换表 6 | 7 | 返回值: 8 | 9 | - Encoding 结构指针 10 | 11 | 功能说明: 12 | 13 | 计算 base32 解码输出需要的最大字节数 14 | 15 | 代码实例: 16 | 17 | ```go 18 | !INCLUDE "NewEncoding_test.go" 19 | ``` 20 | -------------------------------------------------------------------------------- /encoding/base64/examples/CorruptInputError.mdpp: -------------------------------------------------------------------------------- 1 | ## func (e CorruptInputError) Error() string 2 | 3 | 参数列表: 4 | 5 | 无 6 | 7 | 返回值: 8 | 9 | - 错误描述 10 | 11 | 功能说明: 12 | 13 | 返回错误描述 14 | 15 | 代码实例: 16 | 17 | ```go 18 | !INCLUDE "CorruptInputError_test.go" 19 | ``` 20 | -------------------------------------------------------------------------------- /encoding/base64/examples/Decode.mdpp: -------------------------------------------------------------------------------- 1 | ## func (enc *Encoding) Decode(dst, src []byte) (n int, err error) 2 | 3 | 参数列表: 4 | 5 | - dst 解码缓冲区 6 | - src 要解码的字符串切片 7 | 8 | 返回值: 9 | 10 | - n 解码到缓冲区的字节数 11 | - err 可能的错误 12 | 13 | 功能说明: 14 | 15 | 对输入的字符串进行 base64 解码 16 | 17 | 代码实例: 18 | 19 | ```go 20 | !INCLUDE "Decode_test.go" 21 | ``` 22 | -------------------------------------------------------------------------------- /encoding/base64/examples/DecodeString.mdpp: -------------------------------------------------------------------------------- 1 | ## func (enc *Encoding) DecodeString(s string) ([]byte, error) 2 | 3 | 参数列表: 4 | 5 | - s 要进行 base64 解码的字符串 6 | 7 | 返回值: 8 | 9 | - 经过 base64 解码后的字符串切片 10 | - 可能的错误 11 | 12 | 功能说明: 13 | 14 | 对传入的字符串进行 base64 解码 15 | 16 | 代码实例: 17 | 18 | ```go 19 | !INCLUDE "DecodeString_test.go" 20 | ``` 21 | -------------------------------------------------------------------------------- /encoding/base64/examples/DecodedLen.mdpp: -------------------------------------------------------------------------------- 1 | ## func (enc *Encoding) DecodedLen(n int) int 2 | 3 | 参数列表: 4 | 5 | - n 要进行 base64 解码的字节数 6 | 7 | 返回值: 8 | 9 | - base64 解码输出需要的最大字节数 10 | 11 | 功能说明: 12 | 13 | 计算 base64 解码输出需要的最大字节数 14 | 15 | 代码实例: 16 | 17 | ```go 18 | !INCLUDE "DecodedLen_test.go" 19 | ``` 20 | -------------------------------------------------------------------------------- /encoding/base64/examples/DecodedLen_test.go: -------------------------------------------------------------------------------- 1 | package examples 2 | 3 | import ( 4 | "fmt" 5 | "encoding/base64" 6 | ) 7 | 8 | func ExampleDecodedLen1() { 9 | 10 | src := "dGhpcyBpcyBhIHRlc3Qgc3RyaW5nLg==" 11 | 12 | // 解码需要的缓冲区的最大长度 13 | l := base64.StdEncoding.DecodedLen(len(src)) 14 | 15 | dst, _ := base64.StdEncoding.DecodeString(src) 16 | fmt.Println(len(dst) <= l) 17 | 18 | // Output: 19 | // true 20 | } 21 | -------------------------------------------------------------------------------- /encoding/base64/examples/Encode.mdpp: -------------------------------------------------------------------------------- 1 | ## func (enc *Encoding) Encode(dst, src []byte) 2 | 3 | 参数列表: 4 | 5 | - dst 编码缓冲区 6 | - src 要编码的字符串切片 7 | 8 | 返回值: 9 | 10 | 无 11 | 12 | 功能说明: 13 | 14 | 对输入的字符串进行 base64 编码 15 | 16 | 代码实例: 17 | 18 | ```go 19 | !INCLUDE "Encode_test.go" 20 | ``` 21 | -------------------------------------------------------------------------------- /encoding/base64/examples/EncodeToString.mdpp: -------------------------------------------------------------------------------- 1 | ## func (enc *Encoding) EncodeToString(src []byte) string 2 | 3 | 参数列表: 4 | 5 | - src 要进行 base64 编码的字符串切片 6 | 7 | 返回值: 8 | 9 | - 经过 base64 编码后的字符串 10 | 11 | 功能说明: 12 | 13 | 对传入的字符串切片进行 base64 编码 14 | 15 | 代码实例: 16 | 17 | ```go 18 | !INCLUDE "EncodeToString_test.go" 19 | ``` 20 | -------------------------------------------------------------------------------- /encoding/base64/examples/EncodedLen.mdpp: -------------------------------------------------------------------------------- 1 | ## func (enc *Encoding) EncodedLen(n int) int 2 | 3 | 参数列表: 4 | 5 | - n 要进行 base64 编码的字节数 6 | 7 | 返回值: 8 | 9 | - 经过 base64 编码后的字节数 10 | 11 | 功能说明: 12 | 13 | 计算编码输出的字节数 14 | 15 | 代码实例: 16 | 17 | ```go 18 | !INCLUDE "EncodedLen_test.go" 19 | ``` 20 | -------------------------------------------------------------------------------- /encoding/base64/examples/EncodedLen_test.go: -------------------------------------------------------------------------------- 1 | package examples 2 | 3 | import ( 4 | "fmt" 5 | "encoding/base64" 6 | ) 7 | 8 | func ExampleEncodedLen1() { 9 | 10 | src := []byte("this is a test string.") 11 | 12 | // 编码需要的缓冲区长度 13 | l := base64.StdEncoding.EncodedLen(len(src)) 14 | 15 | dst := base64.StdEncoding.EncodeToString(src) 16 | fmt.Println(len(dst) == l) 17 | 18 | // Output: 19 | // true 20 | 21 | } 22 | -------------------------------------------------------------------------------- /encoding/base64/examples/NewDecoder.mdpp: -------------------------------------------------------------------------------- 1 | ## func NewDecoder(enc *Encoding, r io.Reader) io.Reader 2 | 3 | 参数列表: 4 | 5 | - enc Encoding 结构指针 6 | - w io.Reader 接口 7 | 8 | 返回值: 9 | 10 | - io.Reader 接口 11 | 12 | 功能说明: 13 | 14 | 返回一个 io.Reader 接口,用于流式解码 15 | 16 | 代码实例: 17 | 18 | ```go 19 | !INCLUDE "NewDecoder_test.go" 20 | ``` 21 | -------------------------------------------------------------------------------- /encoding/base64/examples/NewEncoder.mdpp: -------------------------------------------------------------------------------- 1 | ## func NewEncoder(enc *Encoding, w io.Writer) io.WriteCloser 2 | 3 | 参数列表: 4 | 5 | - enc Encoding 结构指针 6 | - w io.Writer 接口 7 | 8 | 返回值: 9 | 10 | - io.WriteCloser 接口 11 | 12 | 功能说明: 13 | 14 | 返回一个 io.WriteCloser 接口,用于流式编码 15 | 16 | 代码实例: 17 | 18 | ```go 19 | !INCLUDE "NewEncoder_test.go" 20 | ``` 21 | -------------------------------------------------------------------------------- /encoding/base64/examples/NewEncoding.mdpp: -------------------------------------------------------------------------------- 1 | ## func NewEncoding(encoder string) *Encoding 2 | 3 | 参数列表: 4 | 5 | - encoder 64字节长的字符串,用做转换表 6 | 7 | 返回值: 8 | 9 | - Encoding 结构指针 10 | 11 | 功能说明: 12 | 13 | 计算 base64 解码输出需要的最大字节数 14 | 15 | 代码实例: 16 | 17 | ```go 18 | !INCLUDE "NewEncoding_test.go" 19 | ``` 20 | -------------------------------------------------------------------------------- /encoding/binary/Size.md: -------------------------------------------------------------------------------- 1 | ## func Size(v interface{}) int 2 | 3 | ###参数列表 4 | 5 | - v 需要计算长度的数据 6 | 7 | ###返回值: 8 | 9 | - int 数据序列化之后的字节长度 10 | 11 | ###功能说明: 12 | 13 | Size将返回数据序列化之后的字节长度,数据必须是固定长数据类型、slice和结构体及其指针等。 14 | 15 | ###代码实例: 16 | package main 17 | 18 | import ( 19 | "encoding/binary" 20 | "fmt" 21 | ) 22 | 23 | func main() { 24 | var a int 25 | b := [5]int64{1} 26 | 27 | fmt.Println(binary.Size(a)) //-1 28 | fmt.Println(binary.Size(b)) //40 29 | } 30 | -------------------------------------------------------------------------------- /encoding/csv/README.md: -------------------------------------------------------------------------------- 1 | # encoding/csv包函数列表 2 | 3 | - [func (e *ParseError) Error() string](Error.md) 4 | - [func NewReader(r io.Reader) *Reader](NewReader.md) 5 | - [func (r *Reader) Read() (record []string, err error)](Read.md) 6 | - [func (r *Reader) ReadAll() (records [][]string, err error)](ReadAll.md) 7 | - [func NewWriter(w io.Writer) *Writer](NewWriter.md) 8 | - [func (w *Writer) Flush()](Flush.md) 9 | - [func (w *Writer) Write(record []string) (err error)](Write.md) 10 | - [func (w *Writer) WriteAll(records [][]string) (err error)](WriteAll.md) -------------------------------------------------------------------------------- /encoding/gob/Decode.md: -------------------------------------------------------------------------------- 1 | func (dec *Decoder) Decode(e interface{}) error 2 | 3 | 4 | 参数列表: 5 | - e 空接口类型,可以处理任何类型的数据 6 | 7 | 返回值: 8 | - error 9 | 10 | 功能说明: 11 | 此函数是Decoder的方法即(Method),需要使用NewDecoder()创建*Decoder对象后,才可以使用 12 | 13 | 代码: 14 | [Decode_Encode.go](Decode_Encode.go) 15 | 16 | 17 | -------------------------------------------------------------------------------- /encoding/gob/Encode.md: -------------------------------------------------------------------------------- 1 | func (enc *Encoder) Encode(e interface{}) error 2 | 3 | 参数列表: 4 | 5 | - v 序列化gob对象 6 | 7 | 返回值: 8 | 9 | - error 错误 10 | 11 | 功能说明: 12 | 13 | 这个函数主要是将encode编码的gob数据写入到相关联的对象 14 | 15 | 代码: 16 | [Decode_Encode.go](Decode_Encode.go) 17 | 18 | -------------------------------------------------------------------------------- /encoding/gob/NewDecoder.md: -------------------------------------------------------------------------------- 1 | func NewDecoder(r io.Reader) *Decoder 2 | 3 | 参数列表: 4 | 5 | - r Reader对象 6 | 7 | 返回值: 8 | 9 | - *Decoder 指向Decoder的指针 10 | 11 | 功能说明: 12 | 13 | 这个函数主要是给r创建一个decoder实例 14 | 15 | 代码: 16 | 17 | [gob.go](gob.go) 18 | 19 | -------------------------------------------------------------------------------- /encoding/gob/NewEncoder.md: -------------------------------------------------------------------------------- 1 | func NewEncoder(w io.writer) *Encoder 2 | 3 | 参数列表: 4 | 5 | - r Writer对象 6 | 7 | 返回值: 8 | 9 | - *Encoderr 指向Encoder的指针 10 | 11 | 功能说明: 12 | 13 | 这个函数主要是给w创建一个encoder实例 14 | 15 | 16 | 代码: 17 | 18 | [gob.go](gob.go) 19 | 20 | 21 | -------------------------------------------------------------------------------- /encoding/hex/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /encoding/json/TestHTMLEscape.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "os" 7 | ) 8 | 9 | type ColorGroup struct { 10 | ID int 11 | Name string 12 | Colors []string 13 | } 14 | 15 | func main() { 16 | group := ColorGroup{ 17 | ID: 1, 18 | Name: "Reds", 19 | Colors: []string{"Crimson", "Red", "Ruby", "Maroon"}, 20 | } 21 | encoder := json.NewEncoder(os.Stdout) 22 | if err := encoder.Encode(group); err != nil { 23 | fmt.Printf("failed encoding to writer: %s", err) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /encoding/json/json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astaxie/gopkg/ac1fbcc823ecf390730a2a9665cad913643a23aa/encoding/json/json -------------------------------------------------------------------------------- /encoding/pem/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /encoding/xml/README.md: -------------------------------------------------------------------------------- 1 | # xml 2 | 3 | 函数列表 4 | 5 | - [func Escape(w io.Writer, s []byte)](Escape.md) 6 | - [func Marshal(v interface{}) ([]byte, error)](Marshal.md) 7 | - [func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error)](MarshalIndent.md) 8 | -------------------------------------------------------------------------------- /errors/New.md: -------------------------------------------------------------------------------- 1 | # func New(text string) error 2 | 3 | 参数列表 4 | 5 | - text 错误字符串 6 | 7 | 返回值: 8 | 9 | - 返回error 10 | 11 | 功能说明: 12 | 13 | New returns an error that formats as the given text. 14 | 按给定的文本返回一个新的 error. 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import "fmt" 21 | import "errors" 22 | 23 | func main(){ 24 | fmt.Println(errors.New("Err")) 25 | } 26 | 27 | -------------------------------------------------------------------------------- /errors/README.md: -------------------------------------------------------------------------------- 1 | # errors 包函数列表 2 | 3 | - [func New(text string) error](New.md) 4 | 5 | 6 | -------------------------------------------------------------------------------- /fmt/Errorf.md: -------------------------------------------------------------------------------- 1 | # func Errorf(format string, a ...interface{}) error 2 | 3 | 参数列表 4 | 5 | - format 打印的格式说明 6 | - a... 值变量列表 7 | 8 | 返回值: 9 | 10 | - 返回error 11 | 12 | 功能说明: 13 | 14 | 这个函数主要是用来根据格式字符串和参数表生成一个字符串,该字符串满足error接口 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import "fmt" 21 | 22 | func main() { 23 | fmt.Errorf("Error:%s\n","Test error!") 24 | } 25 | -------------------------------------------------------------------------------- /fmt/Exfmt02.go: -------------------------------------------------------------------------------- 1 | // Exfmt02.go 2 | // 测试和说明: 3 | // %t 值的true和false 4 | // %T 值的类型在Go语言中的表示 5 | // %% 打印一个 % 6 | // %q 给打印的字串自动加引号 7 | package main 8 | 9 | import "fmt" 10 | 11 | func main() { 12 | var Yes bool //bool 变量自动初始化为 false 13 | fmt.Printf("No01:%t\n", Yes) 14 | fmt.Printf("No02:%T\n", Yes) 15 | fmt.Printf("No03:%%\n") 16 | fmt.Printf("No04:%q\n","自动加引号") 17 | } 18 | // 输出: 19 | //No01:false 20 | //No02:bool 21 | //No03:% 22 | //No04:"自动加引号" 23 | -------------------------------------------------------------------------------- /fmt/Exfmt05.go: -------------------------------------------------------------------------------- 1 | // Exfmt05.go 2 | // 测试和说明: 3 | // "No01:%.*d",10,123: 打印整数,并保证10为长度,关键是长度运行时动态传入 4 | // "No02:%6.*f",2,888.666: 打印浮点数,并保证两位小数,关键是小数位运行时动态传入 5 | package main 6 | 7 | import "fmt" 8 | 9 | func main() { 10 | fmt.Printf("No01:%.*d\n",10,123) 11 | fmt.Printf("No02:%6.*f\n",2,888.666) 12 | } 13 | // 输出: 14 | //No01:0000000123 15 | //No02:888.67 16 | -------------------------------------------------------------------------------- /fmt/Fprint.md: -------------------------------------------------------------------------------- 1 | # func Fprint(w io.Writer, a ...interface{}) (n int, err error) 2 | 3 | 参数列表 4 | 5 | - w 写入文件指针 6 | - a... 值变量列表 7 | 8 | 返回值: 9 | 10 | - 返回打印字符数 n 11 | - 返回error 12 | 13 | 功能说明: 14 | 15 | 这个函数主要是用来根据默认格式字符串和参数表生成一个打印字符串并写入指定文件 16 | 17 | 代码实例: 18 | 19 | package main 20 | 21 | import "fmt" 22 | import "os" 23 | 24 | func main() { 25 | fmt.Fprint(os.Stdout,"默认格式打印!") 26 | } 27 | -------------------------------------------------------------------------------- /fmt/Fprintf.md: -------------------------------------------------------------------------------- 1 | # func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) 2 | 3 | 参数列表 4 | 5 | - w 写入文件指针 6 | - format 打印的格式说明 7 | - a... 值变量列表 8 | 9 | 返回值: 10 | 11 | - 返回打印字符数 n 12 | - 返回error 13 | 14 | 功能说明: 15 | 16 | 这个函数主要是用来根据说明格式字符串和参数表生成一个打印字符串 17 | 18 | 代码实例: 19 | 20 | package main 21 | 22 | import "fmt" 23 | import "os" 24 | 25 | func main() { 26 | fmt.Fprintf(os.Stdout,"Format:%s\n","格式打印!") 27 | } 28 | -------------------------------------------------------------------------------- /fmt/Fprintln.md: -------------------------------------------------------------------------------- 1 | # func Fprintln(w io.Writer,a ...interface{}) (n int, err error) 2 | 3 | 参数列表 4 | 5 | - w 写入文件指针 6 | - a... 值变量列表 7 | 8 | 返回值: 9 | 10 | - 返回打印字符数 n 11 | - 返回error 12 | 13 | 功能说明: 14 | 15 | 这个函数主要是用来根据默认格式字符串和参数表生成一个打印字符串并加换行写入指定文件 16 | 17 | 代码实例: 18 | 19 | package main 20 | 21 | import "fmt" 22 | import "os" 23 | 24 | func main() { 25 | fmt.Fprintln(os.Stdout,"默认格式加换行打印!") 26 | } 27 | -------------------------------------------------------------------------------- /fmt/Print.md: -------------------------------------------------------------------------------- 1 | # func Print(a ...interface{}) (n int, err error) 2 | 3 | 参数列表 4 | 5 | - a... 值变量列表 6 | 7 | 返回值: 8 | 9 | - 返回打印字符数 n 10 | - 返回error 11 | 12 | 功能说明: 13 | 14 | 这个函数主要是用来根据系统默认格式字符串和参数表生成一个打印字符串 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import "fmt" 21 | 22 | func main() { 23 | fmt.Print("默认格式打印!") 24 | } 25 | -------------------------------------------------------------------------------- /fmt/Printf.md: -------------------------------------------------------------------------------- 1 | # func Printf(format string, a ...interface{}) (n int, err error) 2 | 3 | 参数列表 4 | 5 | - format 打印的格式说明 6 | - a... 值变量列表 7 | 8 | 返回值: 9 | 10 | - 返回打印字符数 n 11 | - 返回error 12 | 13 | 功能说明: 14 | 15 | 这个函数主要是用来根据说明格式字符串和参数表生成一个打印字符串 16 | 17 | 代码实例: 18 | 19 | package main 20 | 21 | import "fmt" 22 | 23 | func main() { 24 | fmt.Printf("Format:%s\n","格式打印!") 25 | } 26 | -------------------------------------------------------------------------------- /fmt/Println.md: -------------------------------------------------------------------------------- 1 | # func Println(a ...interface{}) (n int, err error) 2 | 3 | 参数列表 4 | 5 | - a... 值变量列表 6 | 7 | 返回值: 8 | 9 | - 返回打印字符数 n 10 | - 返回error 11 | 12 | 功能说明: 13 | 14 | 这个函数主要是用来根据系统默认格式字符串和参数表生成一个打印字符串并加换行 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import "fmt" 21 | 22 | func main() { 23 | fmt.Println("默认格式打印,有换行啊!") 24 | } 25 | -------------------------------------------------------------------------------- /fmt/Scan.md: -------------------------------------------------------------------------------- 1 | # func Scan(a ...interface{}) (n int, err error) 2 | 3 | 参数列表 4 | 5 | - a... 值变量列表 6 | 7 | 返回值: 8 | 9 | - 返回成功读取的参数的数量 n 10 | - 返回error 11 | 12 | 功能说明: 13 | 14 | >这个函数主要是从标准输入读取文本,将空白分割的连续数据顺序存入参数里。 15 | > 16 | >换行视同空白。它返回成功读取的参数的数量。 17 | > 18 | >如果少于提供的参数的数量,返回值err将报告原因。 19 | > 20 | 21 | 代码实例: 22 | 23 | package main 24 | 25 | import "fmt" 26 | 27 | func main(){ 28 | var a,b,c int 29 | fmt.Scan(&a,&b,&c) 30 | fmt.Println(a,b,c) 31 | } 32 | 33 | 34 | -------------------------------------------------------------------------------- /fmt/Sprint.md: -------------------------------------------------------------------------------- 1 | # func Sprint(a ...interface{}) string 2 | 3 | 参数列表 4 | 5 | - a... 值变量列表 6 | 7 | 返回值: 8 | 9 | - 返回打印字符串 10 | 11 | 功能说明: 12 | 13 | 这个函数主要是用来根据默认格式字符串和参数表生成一个打印字符串 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import "fmt" 20 | 21 | func main() { 22 | fmt.Sprint("默认格式打印出字符串!") 23 | } 24 | -------------------------------------------------------------------------------- /fmt/Sprintf.md: -------------------------------------------------------------------------------- 1 | # func Sprintf(format string, a ...interface{}) string 2 | 3 | 参数列表 4 | 5 | - format 打印的格式说明 6 | - a... 值变量列表 7 | 8 | 返回值: 9 | 10 | - 返回打印字符串 11 | 12 | 功能说明: 13 | 14 | 这个函数主要是用来根据说明格式字符串和参数表生成一个打印字符串 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import "fmt" 21 | 22 | func main() { 23 | str := fmt.Sprintf("Format:%s\n","格式打印出字符串!") 24 | fmt.Println(str) // Format:格式打印出字符串! 25 | } 26 | -------------------------------------------------------------------------------- /fmt/Sprintln.md: -------------------------------------------------------------------------------- 1 | # func Sprintln(a ...interface{}) string 2 | 3 | 参数列表 4 | 5 | - a... 值变量列表 6 | 7 | 返回值: 8 | 9 | - 返回打印字符串 10 | 11 | 功能说明: 12 | 13 | 这个函数主要是用来根据默认格式字符串和参数表生成一个打印字符串并带换行 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import "fmt" 20 | 21 | func main() { 22 | fmt.Sprintln("默认格式打印出字符串并带换行!") 23 | } 24 | -------------------------------------------------------------------------------- /go/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /go/ast/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /go/build/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /go/doc/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /go/parser/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /go/printer/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /go/scanner/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /go/token/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /hash/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /hash/adler32/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /hash/crc32/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /hash/crc64/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /hash/fnv/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /html/README.md: -------------------------------------------------------------------------------- 1 | #html包 2 | 3 | ##概述 4 | 提供了HTML文本转义与反转义的函数 5 | 6 | ##函数列表 7 | - [func EscapeString(s string) string](EscapeString.md) 8 | - [func UnescapeString(s string) string](UnescapeString.md) 9 | 10 | ##子包 11 | - [template](template) (html/template) 实现了数据驱动的模板引擎,生成HTML输出并可防止代码注入 -------------------------------------------------------------------------------- /html/template/HTMLEscapeString.md: -------------------------------------------------------------------------------- 1 | #func HTMLEscapeString(s string) string 2 | 3 | ##参数 4 | - s string 需要进行转义的字符串 5 | 6 | ##返回 7 | - string 转义后的字符串 8 | 9 | ##功能说明 10 | HTMLEscapeString返回s转义后的HTML文本. 11 | 12 | ##代码示例 13 | 14 | package main 15 | 16 | import ( 17 | "fmt" 18 | "html/template" 19 | ) 20 | 21 | func main() { 22 | 23 | s := "" 24 | 25 | fmt.Println(template.HTMLEscapeString(s)) 26 | 27 | } 28 | 29 | 输出: 30 | `<script>alert('xss!')</script>` 31 | -------------------------------------------------------------------------------- /image/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /image/color/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /image/draw/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /image/gif/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /image/jpeg/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /image/png/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /index/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /index/suffixarray/Bytes.md: -------------------------------------------------------------------------------- 1 | ## func (x *Index) Bytes() []byte 2 | 参数列表 3 | 4 | - 无 5 | 6 | 返回值 7 | 8 | - 返回[]byte类型 9 | 10 | 功能说明: 获取Index的数据 11 | 12 | 代码示例 13 | 14 | package main 15 | 16 | import ( 17 | "fmt" 18 | "index/suffixarray" 19 | ) 20 | 21 | func main() { 22 | data := []byte("aaaa") 23 | index := suffixarray.New(data) 24 | fmt.Println(index.Bytes()) //[97,97,97,97] 25 | } -------------------------------------------------------------------------------- /index/suffixarray/New.md: -------------------------------------------------------------------------------- 1 | ## func New(data []byte) *Index 2 | 参数列表 3 | 4 | - data 需要创建Index的数据 5 | 6 | 返回值 7 | 8 | - 返回Index类型 9 | 10 | 功能说明: 创建一个索引 11 | 12 | 代码示例 13 | 14 | package main 15 | 16 | import ( 17 | "fmt" 18 | "index/suffixarray" 19 | ) 20 | 21 | func main() { 22 | data := []byte("aaaa") 23 | index := suffixarray.New(data) 24 | 25 | } -------------------------------------------------------------------------------- /index/suffixarray/README.md: -------------------------------------------------------------------------------- 1 | # suffixarray函数包列表 2 | 3 | 函数列表 4 | 5 | - [func New(data []byte) *Index](New.md) 6 | - [func (x *Index) Bytes() []byte](Bytes.md) 7 | - [func (x *Index) FindAllIndex(r *regexp.Regexp, n int) (result [][]int)](FindAllIndex.md) 8 | - [func (x *Index) Lookup(s []byte, n int) (result []int)](Lookup.md) 9 | - [func (x *Index) Read(r io.Reader) error](Read.md) 10 | - [func (x *Index) Write(w io.Writer) error](Write.md) 11 | -------------------------------------------------------------------------------- /io/LimitReader.md: -------------------------------------------------------------------------------- 1 | # func LimitReader(r Reader, n int64) Reader 2 | 3 | 参数: 4 | - r 读取器 5 | - n 限定字节数 6 | 7 | 返回值:LimitReader对象 8 | 9 | LimitReader对象说明: 10 | - 是对Reader对象的一种封装,限定Reader数据的读取数量 11 | 12 | 功能说明: 13 | - 获得一个只能从r读取n比特数据的Reader 14 | 15 | 示例: 16 | package main 17 | 18 | import ( 19 | "io" 20 | "fmt" 21 | "os" 22 | "reflect" 23 | ) 24 | 25 | func main() { 26 | reader, _ := os.Open("readFile.txt") 27 | limitReader := io.LimitReader(reader, 20) 28 | fmt.Println(reflect.TypeOf(limitReader)) 29 | } 30 | -------------------------------------------------------------------------------- /io/Pipe.md: -------------------------------------------------------------------------------- 1 | # func Pipe() (*PipeReader, *PipeWriter) 2 | 3 | 返回值: 4 | - PipeReader:管道读取器 5 | - PipeWriter:管道写入器 6 | 7 | 功能说明: 8 | - 创建一个管道,并返回它的读取器和写入器 9 | 10 | 示例: 11 | package main 12 | 13 | import ( 14 | "io" 15 | "fmt" 16 | "reflect" 17 | ) 18 | 19 | func main() { 20 | reader, writer := io.Pipe() 21 | fmt.Println(reflect.TypeOf(reader)) 22 | fmt.Println(reflect.TypeOf(writer)) 23 | } 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /io/TeeReader.md: -------------------------------------------------------------------------------- 1 | # func TeeReader(r Reader, w Writer) Reader 2 | 3 | 参数: 4 | - r 源读取器 5 | - w 目标写入去 6 | 7 | 返回值:TeeReader对象 8 | 9 | TeeReader对象说明: 10 | - 是对Reader对象的一种封装,从r中读取写入并写入w中 11 | 12 | 功能说明: 13 | - 创建一个TeeReader对象 14 | 15 | 示例: 16 | package main 17 | 18 | import ( 19 | "io" 20 | "os" 21 | "fmt" 22 | "reflect" 23 | ) 24 | 25 | func main() { 26 | reader, _ := os.Open("copySrc.txt") 27 | writer, _ := os.Create("copyDest.txt") 28 | teeReader := io.TeeReader(reader, writer) 29 | fmt.Println(reflect.TypeOf(teeReader)) 30 | } 31 | -------------------------------------------------------------------------------- /io/WriteString.md: -------------------------------------------------------------------------------- 1 | # func WriteString(w Writer, s string) (n int, err error) 2 | 3 | 参数: 4 | - w 目标写入器 5 | - s 写入的字符串 6 | 7 | 返回值: 8 | - n 写入字节数 9 | - err 写入是否成功,nil代表成功 10 | 11 | 功能说明: 12 | - 将字符串s写入到w中 13 | 14 | 示例: 15 | package main 16 | 17 | import ( 18 | "io" 19 | "fmt" 20 | "os" 21 | ) 22 | 23 | func main() { 24 | writer, _ := os.Create("dst.txt") 25 | data := "write data.." 26 | n, err := io.WriteString(writer, data) 27 | if err == nil { 28 | fmt.Println("Success write", n, "byte") 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /io/ioutil/NopCloser.md: -------------------------------------------------------------------------------- 1 | # func NopCloser(r io.Reader) io.ReadCloser 2 | 3 | 参数列表 4 | 5 | - r 读取对象 6 | 7 | 返回值: 8 | 9 | - 返回一个读取对象ReadCloser接口,该接口仅提供Close方法。 10 | 11 | 功能说明: 12 | 13 | 本函数主要是用来返回一个读取对象的ReadCloser接口,该接口仅提供Close方法 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import "io/ioutil" 20 | import "strings" 21 | 22 | func main() { 23 | s := strings.NewReader("hello world!") 24 | r := ioutil.NopCloser(s) 25 | defer r.Close() 26 | } 27 | -------------------------------------------------------------------------------- /io/ioutil/README.md: -------------------------------------------------------------------------------- 1 | # 包名 ioutil 2 | 3 | 函数列表 4 | 5 | - [func NopCloser(r io.Reader) io.ReadCloser](NopCloser.md) 6 | - [func ReadAll(r io.Reader) ([]byte, error)](ReadAll.md) 7 | - [func ReadDir(dirname string) ([]os.FileInfo, error)](ReadDir.md) 8 | - [func ReadFile(filename string) ([]byte, error)](ReadFile.md) 9 | - [func TempDir(dir, prefix string) (name string, err error)](TempDir.md) 10 | - [func TempFile(dir, prefix string) (f *os.File, err error)](TempFile.md) 11 | -------------------------------------------------------------------------------- /log/Constants.md: -------------------------------------------------------------------------------- 1 | # 常量 2 | 3 | 常量列表: 4 | 5 | ~~~ 6 | - Ldate 日期 年/月/日 7 | - Ltime 时间 时:分:秒 8 | - Lmicroseconds 时间 .毫秒于Ltime之后 9 | - Llongfile 完整文件名:行号 10 | - Lshortfile 文件名,此标志位优先于 Llongfile 11 | - LstdFlags = Ldate 并且 Ltime 12 | ~~~ 13 | 14 | 功能说明: 15 | 16 | 标志位常量控制日志格式。 17 | 18 | 代码实例: 19 | ```go 20 | package main 21 | 22 | import "log" 23 | 24 | func main() { 25 | log.SetFlags(log.Lshortfile | log.LstdFlags) 26 | log.Println("log:") 27 | } 28 | ``` 29 | 30 | 输出: 31 | ~~~ 32 | 2009/11/10 23:00:00 log.go:7: log: 33 | ~~~ 34 | -------------------------------------------------------------------------------- /log/Fatal.md: -------------------------------------------------------------------------------- 1 | ## func Fatal(v ...interface{}) 2 | 3 | 参数列表: 4 | 5 | - v 待输出参数列表 6 | 7 | 返回值: 8 | 9 | - 无 10 | 11 | 功能说明: 12 | 13 | 打印日志并退出。相当于调用Print()并os.Exit(1) 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import( 20 | "log" 21 | ) 22 | 23 | func main(){ 24 | 25 | age := 25 26 | log.Fatal("Hi & Bye ! Age = ", age)// this will print "Hi & Bye ! Age = 25" 27 | 28 | log.Println("This will not be called.") 29 | } 30 | 31 | -------------------------------------------------------------------------------- /log/Fatalf.md: -------------------------------------------------------------------------------- 1 | ## func Fatalf(format string, v ...interface{}) 2 | 3 | 参数列表: 4 | 5 | - format 输出格式 6 | - v 带输出参数列表 7 | 8 | 返回值: 9 | 10 | - 无 11 | 12 | 功能说明: 13 | 14 | 按格式输出日志,并退出。相当于调用Printf()并调用os.Exit(1) 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import( 21 | "log" 22 | ) 23 | 24 | func main(){ 25 | 26 | //log.Fatalf("%s", "hello") 27 | 28 | name := "golang" 29 | log.Fatalf("%8d,%8s", 23, name) //2013/03/10 16:08:49 23, golang 30 | } 31 | 32 | -------------------------------------------------------------------------------- /log/Fatalln.md: -------------------------------------------------------------------------------- 1 | ## func Fatalln(v ...interface{}) 2 | 3 | 参数列表: 4 | 5 | - v 6 | 7 | 返回值: 8 | 9 | - 无 10 | 11 | 功能说明: 12 | 13 | 打印一行日志并退出。相当于调用Println()并os.Exit(1) 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import( 20 | "log" 21 | ) 22 | 23 | func main(){ 24 | 25 | log.Fatalln("bye!")//2013/03/10 16:14:54 bye!\n 26 | } 27 | 28 | -------------------------------------------------------------------------------- /log/Output.md: -------------------------------------------------------------------------------- 1 | ## func (l *Logger) Output(calldepth int, s string) error 2 | 3 | 参数列表: 4 | 5 | - calldepth 深度 6 | - s 字符串 7 | 8 | 返回值: 9 | 10 | - error 错误 11 | 12 | 功能说明: 13 | 14 | 输出日志事件。字符串s包含待打印内容,跟在预定义的prefix后面,并且根据flags设置会有区分。如果s末尾没有换行符,这个方法会默认加上一个。calldepth目前预定义均为2,以后会用来支持通用场景,支持其他值配置。(本人注:日志输出不建议直接使用该方法) 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import( 21 | "log" 22 | "os" 23 | ) 24 | 25 | func main(){ 26 | 27 | l := log.New(os.Stdout, "log->", log.Ldate) 28 | 29 | l.Output(2, "log output") 30 | } 31 | 32 | -------------------------------------------------------------------------------- /log/Prefix.md: -------------------------------------------------------------------------------- 1 | ## func Prefix() string 2 | 3 | 参数列表: 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - 标准logger前缀,字符串类型 10 | 11 | 功能说明: 12 | 13 | 返回标准logger的输出前缀 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import( 20 | "log" 21 | "fmt" 22 | ) 23 | 24 | func main(){ 25 | 26 | fmt.Print(log.Prefix()) //this will print nothing 27 | 28 | log.Println(1) //2013/03/10 17:02:05 1 29 | 30 | log.SetPrefix("log:") 31 | fmt.Println(log.Prefix()) //log: 32 | 33 | log.Println(2) //log:2013/03/10 17:02:05 2 34 | } 35 | 36 | -------------------------------------------------------------------------------- /log/Print.md: -------------------------------------------------------------------------------- 1 | ## func Print(v ...interface{}) 2 | 3 | 参数列表: 4 | 5 | - v 待输出参数列表 6 | 7 | 返回值: 8 | 9 | - 无 10 | 11 | 功能说明: 12 | 13 | 输出日志到标准logger。参数处理方式同fmt.Print 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import( 20 | "log" 21 | ) 22 | 23 | func main(){ 24 | log.Print("string", 1, 2.3)//2013/03/10 17:26:06 string1 2.3 25 | } 26 | 27 | -------------------------------------------------------------------------------- /log/Printf.md: -------------------------------------------------------------------------------- 1 | ## func Printf(format string, v ...interface{}) 2 | 3 | 参数列表: 4 | 5 | - format 输出格式 6 | - v 待输出参数列表 7 | 8 | 返回值: 9 | 10 | - 无 11 | 12 | 功能说明: 13 | 14 | 调用Output输出日志到标准logger。参数处理方式同fmt.Printf 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import( 21 | "log" 22 | ) 23 | 24 | func main(){ 25 | 26 | log.Printf("%s", "hello") //hello 27 | 28 | name := "golang" 29 | log.Printf("%8d,%8s", 23, name) //2013/03/10 16:08:49 23, golang 30 | } 31 | 32 | -------------------------------------------------------------------------------- /log/Println.md: -------------------------------------------------------------------------------- 1 | ## func Println(v ...interface{}) 2 | 3 | 参数列表: 4 | 5 | - v 6 | 7 | 返回值: 8 | 9 | - 无 10 | 11 | 功能说明: 12 | 13 | 调用Output打印日志到标准logger,参数处理方式同fmt.Println 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import( 20 | "log" 21 | ) 22 | 23 | func main(){ 24 | log.Println("hello") //2013/03/10 17:35:28 hello\n 25 | } 26 | 27 | -------------------------------------------------------------------------------- /log/SetOutput.md: -------------------------------------------------------------------------------- 1 | ## func SetOutput(w io.Writer) 2 | 3 | 参数列表: 4 | 5 | - w 目标流,io.Writer类型 6 | 7 | 返回值: 8 | 9 | - 无 10 | 11 | 功能说明: 12 | 13 | 设置标准logger的输出目标 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import( 20 | "log" 21 | "os" 22 | ) 23 | 24 | func main(){ 25 | 26 | file, err := os.OpenFile("sample.txt", os.O_WRONLY, 0666) 27 | if err != nil{ 28 | panic(err) 29 | } 30 | 31 | defer file.Close() 32 | 33 | log.SetOutput(file) 34 | 35 | log.Println("log to file") 36 | } 37 | 38 | -------------------------------------------------------------------------------- /log/SetPrefix.md: -------------------------------------------------------------------------------- 1 | ## func SetPrefix(prefix string) 2 | 3 | 参数列表: 4 | 5 | - prefix 前缀 6 | 7 | 返回值: 8 | 9 | - 无 10 | 11 | 功能说明: 12 | 13 | 设置logger的输出前缀 14 | 15 | 代码实例: 16 | 17 | 18 | package main 19 | 20 | import( 21 | "log" 22 | "fmt" 23 | ) 24 | 25 | func main(){ 26 | 27 | fmt.Print(log.Prefix()) //this will print nothing 28 | 29 | log.Println(1) //2013/03/10 17:02:05 1 30 | 31 | log.SetPrefix("log:") 32 | fmt.Println(log.Prefix()) //log: 33 | 34 | log.Println(2) //log:2013/03/10 17:02:05 2 35 | } 36 | 37 | -------------------------------------------------------------------------------- /log/lFatal.md: -------------------------------------------------------------------------------- 1 | ## func (l *Logger) Fatal(v ...interface{}) 2 | 3 | 参数列表: 4 | 5 | - v 待输出参数列表 6 | 7 | 返回值: 8 | 9 | - 无 10 | 11 | 功能说明: 12 | 13 | 打印日志并退出。相当于调用l.Print()并os.Exit(1) 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import( 20 | "log" 21 | "os" 22 | ) 23 | 24 | func main(){ 25 | 26 | l := log.New(os.Stdout, "", log.LstdFlags) 27 | age := 25 28 | l.Fatal("Hi & Bye ! Age = ", age)// this will print "Hi & Bye ! Age = 25" 29 | 30 | l.Println("This will not be called.") 31 | } 32 | 33 | -------------------------------------------------------------------------------- /log/lFatalf.md: -------------------------------------------------------------------------------- 1 | ## func Fatalf(format string, v ...interface{}) 2 | 3 | 参数列表: 4 | 5 | - format 输出格式 6 | - v 带输出参数列表 7 | 8 | 返回值: 9 | 10 | - 无 11 | 12 | 功能说明: 13 | 14 | 按格式输出日志,并退出。相当于调用l.Printf()并调用os.Exit(1) 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "log" 22 | "os" 23 | ) 24 | 25 | func main() { 26 | 27 | l := log.New(os.Stdout, "", log.LstdFlags) 28 | //l.Fatalf("%s", "hello") 29 | 30 | name := "golang" 31 | l.Fatalf("%8d,%8s", 23, name) //2013/03/10 16:08:49 23, golang 32 | } 33 | -------------------------------------------------------------------------------- /log/lFatalln.md: -------------------------------------------------------------------------------- 1 | ## func (l *Logger) Fatalln(v ...interface{}) 2 | 3 | 参数列表: 4 | 5 | - v 6 | 7 | 返回值: 8 | 9 | - 无 10 | 11 | 功能说明: 12 | 13 | 打印一行日志并退出。相当于调用l.Println()并os.Exit(1) 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import( 20 | "log" 21 | "os" 22 | ) 23 | 24 | func main(){ 25 | 26 | l := log.New(os.Stdout, "", log.LstdFlags) 27 | l.Fatalln("bye!")//2013/03/10 16:14:54 bye!\n 28 | } 29 | -------------------------------------------------------------------------------- /log/lFlags.md: -------------------------------------------------------------------------------- 1 | ## func (l *Logger) Flags() int 2 | 3 | 参数列表: 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - 当期logger的配置值 10 | 11 | 功能说明: 12 | 13 | 返回当前logger配置值。 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import( 20 | "log" 21 | "fmt" 22 | "os" 23 | ) 24 | 25 | func main(){ 26 | 27 | l := log.New(os.Stdout, "", log.LstdFlags) 28 | fmt.Println("logger l's flags :", l.Flags()) 29 | } 30 | 31 | 32 | -------------------------------------------------------------------------------- /log/lPrint.md: -------------------------------------------------------------------------------- 1 | ## func (l *Logger) Print(v ...interface{}) 2 | 3 | 参数列表: 4 | 5 | - v 待输出参数列表 6 | 7 | 返回值: 8 | 9 | - 无 10 | 11 | 功能说明: 12 | 13 | 输出日志到logger。参数处理方式同fmt.Print 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import( 20 | "log" 21 | "os" 22 | ) 23 | 24 | func main(){ 25 | l := log.New(os.Stdout, "", log.LstdFlags) 26 | l.Print("string", 1, 2.3)//2013/03/10 17:26:06 string1 2.3 27 | } 28 | 29 | -------------------------------------------------------------------------------- /log/lPrintf.md: -------------------------------------------------------------------------------- 1 | ## func (l *Logger) Printf(format string, v ...interface{}) 2 | 3 | 参数列表: 4 | 5 | - format 输出格式 6 | - v 待输出参数列表 7 | 8 | 返回值: 9 | 10 | - 无 11 | 12 | 功能说明: 13 | 14 | 调用l.Output输出日志到logger l。参数处理方式同fmt.Printf 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import( 21 | "log" 22 | "os" 23 | ) 24 | 25 | func main(){ 26 | 27 | l := log.New(os.Stdout, "", log.LstdFlags) 28 | l.Printf("%s", "hello") //hello 29 | 30 | name := "golang" 31 | l.Printf("%8d,%8s", 23, name) //2013/03/10 16:08:49 23, golang 32 | } 33 | 34 | -------------------------------------------------------------------------------- /log/lPrintln.md: -------------------------------------------------------------------------------- 1 | ## func (l *Logger) Println(v ...interface{}) 2 | 3 | 参数列表: 4 | 5 | - v 待输出参数列表 6 | 7 | 返回值: 8 | 9 | - 无 10 | 11 | 功能说明: 12 | 13 | 调用Output打印日志到当前logger,参数处理方式同fmt.Println 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import( 20 | "log" 21 | "os" 22 | ) 23 | 24 | func main(){ 25 | 26 | l := log.New(os.Stdout, "", log.LstdFlags) 27 | l.Println("hello") //2013/03/10 17:35:28 hello\n 28 | } 29 | 30 | -------------------------------------------------------------------------------- /log/syslog/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /math/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /math/big/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /math/cmplx/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /math/rand/Float32.md: -------------------------------------------------------------------------------- 1 | ## func Float32() float32 2 | 3 | 返回值: 4 | 5 | - 返回float32 6 | 7 | 功能说明: 8 | 9 | 10 | 这个函数主要实现返回一个[0.0.1.0)区间的Float32型的数.通常是一个精确到小数点后8位(8x4=32)的浮点数. 11 | 12 | 13 | 代码实例: 14 | 15 | package main 16 | 17 | import ( 18 | "fmt" 19 | "math/rand" 20 | ) 21 | 22 | func main() { 23 | n := 10 24 | i := 0 25 | for i < n { 26 | x := rand.Float32() 27 | fmt.Println(x) 28 | i += 1 29 | } 30 | } 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /math/rand/Float64.md: -------------------------------------------------------------------------------- 1 | ## func Float64() float64 2 | 3 | 返回值: 4 | 5 | - 返回float64 6 | 7 | 功能说明: 8 | 9 | 10 | 这个函数主要实现返回一个[0.0.1.0)区间的Float64型的数.通常是一个精确到小数点后16位(16x4=64)的浮点数. 11 | 12 | 13 | 代码实例: 14 | 15 | package main 16 | 17 | import ( 18 | "fmt" 19 | "math/rand" 20 | ) 21 | 22 | func main() { 23 | n := 10 24 | i := 0 25 | for i < n { 26 | x := rand.Float64() 27 | fmt.Println(x) 28 | i += 1 29 | } 30 | } 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /math/rand/Int.md: -------------------------------------------------------------------------------- 1 | ## func Int() int 2 | 3 | 返回值: 4 | 5 | - 返回int 6 | 7 | 功能说明: 8 | 9 | 10 | 这个函数主要实现返回一个非负伪随机整数. 11 | 12 | 13 | 代码实例: 14 | 15 | package main 16 | 17 | import ( 18 | "fmt" 19 | "math/rand" 20 | ) 21 | 22 | func main() { 23 | n := 10 24 | i := 0 25 | for i < n { 26 | x := rand.Int() 27 | fmt.Println(x) 28 | i += 1 29 | } 30 | } 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /math/rand/Int31.md: -------------------------------------------------------------------------------- 1 | ## func Int31() int32 2 | 3 | 返回值: 4 | 5 | - 返回int32 6 | 7 | 功能说明: 8 | 9 | 10 | 这个函数主要实现返回一个非负伪随机整数,该整数是一个有符号int32型,除去最高位,占31个比特位,范围在[0,2^31-1]之间. 11 | 12 | 13 | 代码实例: 14 | 15 | package main 16 | 17 | import ( 18 | "fmt" 19 | "math/rand" 20 | ) 21 | 22 | func main() { 23 | n := 10 24 | i := 0 25 | for i < n { 26 | x := rand.Int31() 27 | fmt.Println(x) 28 | i += 1 29 | } 30 | } 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /math/rand/Int31n.md: -------------------------------------------------------------------------------- 1 | ## func Int31n(n int32) int32 2 | 3 | 参数列表: 4 | 5 | - n 期望输出随机值的最大限制值 6 | 7 | 返回值: 8 | 9 | - 返回int32 10 | 11 | 功能说明: 12 | 13 | 14 | 返回一个[0,n)之间的非负伪随机整数.如果n<=0会panic. 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "math/rand" 23 | ) 24 | 25 | func main() { 26 | n := 10 27 | i := 0 28 | for i < n { 29 | x := rand.Int31n(5) 30 | fmt.Println(x) 31 | i += 1 32 | } 33 | } 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /math/rand/Int63.md: -------------------------------------------------------------------------------- 1 | ## func Int63() int64 2 | 3 | 返回值: 4 | 5 | - 返回int64 6 | 7 | 功能说明: 8 | 9 | 10 | 这个函数主要实现返回一个非负伪随机整数,该整数是一个有符号int64型,除去最高位,占63个比特位,范围在[0,2^63-1]之间. 11 | 12 | 13 | 代码实例: 14 | 15 | package main 16 | 17 | import ( 18 | "fmt" 19 | "math/rand" 20 | ) 21 | 22 | func main() { 23 | n := 10 24 | i := 0 25 | for i < n { 26 | x := rand.Int63() 27 | fmt.Println(x) 28 | i += 1 29 | } 30 | } 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /math/rand/Int63n.md: -------------------------------------------------------------------------------- 1 | ## func Int63n(n int64) int64 2 | 3 | 参数列表 4 | 5 | - n 期望输出随机值的最大限制值 6 | 7 | 返回值: 8 | 9 | - 返回int64 10 | 11 | 功能说明: 12 | 13 | 14 | 返回一个[0,n)之间的非负伪随机整数.如果n<=0会panic. 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "math/rand" 23 | ) 24 | 25 | func main() { 26 | n := 10 27 | i := 0 28 | for i < n { 29 | x := rand.Int63n(5) 30 | fmt.Println(x) 31 | i += 1 32 | } 33 | } 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /math/rand/Intn.md: -------------------------------------------------------------------------------- 1 | ## func Intn(n int) int 2 | 3 | 参数列表 4 | 5 | - n 期望输出随机值的最大限制值 6 | 7 | 返回值: 8 | 9 | - 返回int 10 | 11 | 功能说明: 12 | 13 | 14 | 返回一个[0,n)之间的非负伪随机整数.如果n<=0会panic. 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "math/rand" 23 | ) 24 | 25 | func main() { 26 | n := 10 27 | i := 0 28 | for i < n { 29 | x := rand.Intn(5) 30 | fmt.Println(x) 31 | i += 1 32 | } 33 | } 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /math/rand/New.md: -------------------------------------------------------------------------------- 1 | ## func New(src Source) *Rand 2 | 3 | 参数列表 4 | 5 | - src Source 6 | 7 | 返回值 8 | 9 | - Rand指针 10 | 11 | 该函数主要返回了一个新的Rand实例,并以src作为随机值产生器. 12 | 13 | 14 | 代码实例 15 | 16 | package main 17 | 18 | import ( 19 | "fmt" 20 | "math/rand" 21 | ) 22 | 23 | func main() { 24 | n := 10 25 | i := 0 26 | 27 | r := rand.New(rand.NewSource(64)) 28 | for i < n { 29 | fmt.Println(r.Int()) 30 | i += 1 31 | } 32 | } 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /math/rand/NewSource.md: -------------------------------------------------------------------------------- 1 | ## func NewSource(seed int64) Source 2 | 3 | 参数列表: 4 | 5 | - int64类型的值作为种子值 6 | 7 | 8 | 返回值: 9 | 10 | - Source结构体 11 | 12 | 功能说明: 13 | 14 | 该函数主要返回一个指定种子的随机数产生器. 15 | 16 | 17 | 代码实例: 18 | 19 | package main 20 | 21 | import ( 22 | "fmt" 23 | "math/rand" 24 | "time" 25 | ) 26 | 27 | func main() { 28 | n := 10 29 | i := 0 30 | 31 | r := rand.New(rand.NewSource(time.Now().UnixNano())) 32 | for i < n { 33 | fmt.Println(r.Int()) 34 | i += 1 35 | } 36 | } 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /math/rand/Perm.md: -------------------------------------------------------------------------------- 1 | ## func Perm(n int) []int 2 | 3 | 参数列表 4 | 5 | - n 期望输出随机值的最大限制值 6 | 7 | 返回值: 8 | 9 | - 返回[]int 10 | 11 | 功能说明: 12 | 13 | 返回一个元素个数是n的slice,里面的元素是0到n-1的整数无重复的随机排列. 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "math/rand" 22 | ) 23 | 24 | func main() { 25 | n := 10 26 | i := 0 27 | for i < n { 28 | x := rand.Perm(5) 29 | fmt.Println(x) 30 | i += 1 31 | } 32 | } 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /math/rand/Rand-Float32.md: -------------------------------------------------------------------------------- 1 | ## func (*Rand) Float32() float32 2 | 3 | 返回值: 4 | 5 | - 返回float32 6 | 7 | 功能说明: 8 | 9 | 10 | 这个函数主要实现返回一个[0.0.1.0)区间的Float32型的数.通常是一个精确到小数点后8位(8x4=32)的浮点数. 11 | 12 | 13 | 代码实例: 14 | 15 | package main 16 | 17 | import ( 18 | "fmt" 19 | "math/rand" 20 | ) 21 | 22 | func main() { 23 | n := 10 24 | i := 0 25 | r := rand.New(rand.NewSource(64)) 26 | for i < n { 27 | x := r.Float32() 28 | fmt.Println(x) 29 | i += 1 30 | } 31 | } 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /math/rand/Rand-Float64.md: -------------------------------------------------------------------------------- 1 | ## func (*Rand) Float64() float64 2 | 3 | 返回值: 4 | 5 | - 返回float64 6 | 7 | 功能说明: 8 | 9 | 10 | 这个函数主要实现返回一个[0.0.1.0)区间的Float64型的数.通常是一个精确到小数点后16位(16x4=64)的浮点数. 11 | 12 | 13 | 代码实例: 14 | 15 | package main 16 | 17 | import ( 18 | "fmt" 19 | "math/rand" 20 | ) 21 | 22 | func main() { 23 | n := 10 24 | i := 0 25 | r := rand.New(rand.NewSource(64)) 26 | for i < n { 27 | x := r.Float64() 28 | fmt.Println(x) 29 | i += 1 30 | } 31 | } 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /math/rand/Rand-Int.md: -------------------------------------------------------------------------------- 1 | ## func (*Rand) Int() int 2 | 3 | 返回值: 4 | 5 | - 返回int 6 | 7 | 功能说明: 8 | 9 | 10 | 这个函数主要实现返回一个非负伪随机整数. 11 | 12 | 13 | 代码实例: 14 | 15 | package main 16 | 17 | import ( 18 | "fmt" 19 | "math/rand" 20 | ) 21 | 22 | func main() { 23 | n := 10 24 | i := 0 25 | r := rand.New(rand.NewSource(64)) 26 | for i < n { 27 | x := r.Int() 28 | fmt.Println(x) 29 | i += 1 30 | } 31 | } 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /math/rand/Rand-Int31.md: -------------------------------------------------------------------------------- 1 | ## func (*Rand) Int31() int32 2 | 3 | 返回值: 4 | 5 | - 返回int32 6 | 7 | 功能说明: 8 | 9 | 10 | 这个函数主要实现返回一个非负伪随机整数,该整数是一个有符号int32型,除去最高位,占31个比特位,范围在[0,2^31-1]之间. 11 | 12 | 13 | 代码实例: 14 | 15 | package main 16 | 17 | import ( 18 | "fmt" 19 | "math/rand" 20 | ) 21 | 22 | func main() { 23 | n := 10 24 | i := 0 25 | r := rand.New(rand.NewSource(64)) 26 | for i < n { 27 | x := r.Int31() 28 | fmt.Println(x) 29 | i += 1 30 | } 31 | } 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /math/rand/Rand-Int31n.md: -------------------------------------------------------------------------------- 1 | ## func (*Rand) Int31n(n int32) int32 2 | 3 | 参数列表 4 | 5 | - n 期望输出随机值的最大限制值 6 | 7 | 返回值: 8 | 9 | - 返回int32 10 | 11 | 功能说明: 12 | 13 | 14 | 返回一个[0,n)之间的非负伪随机整数.如果n<=0会panic. 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "math/rand" 23 | ) 24 | 25 | func main() { 26 | n := 10 27 | i := 0 28 | r := rand.New(rand.NewSource(64)) 29 | for i < n { 30 | x := r.Int31n(5) 31 | fmt.Println(x) 32 | i += 1 33 | } 34 | } 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /math/rand/Rand-Int63.md: -------------------------------------------------------------------------------- 1 | ## func (*Rand) Int63() int64 2 | 3 | 返回值: 4 | 5 | - 返回int64 6 | 7 | 功能说明: 8 | 9 | 10 | 这个函数主要实现返回一个非负伪随机整数,该整数是一个有符号int64型,除去最高位,占63个比特位,范围在[0,2^63-1]之间. 11 | 12 | 13 | 代码实例: 14 | 15 | package main 16 | 17 | import ( 18 | "fmt" 19 | "math/rand" 20 | ) 21 | 22 | func main() { 23 | n := 10 24 | i := 0 25 | r := rand.New(rand.NewSource(64)) 26 | for i < n { 27 | x := r.Int63() 28 | fmt.Println(x) 29 | i += 1 30 | } 31 | } 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /math/rand/Rand-Int63n.md: -------------------------------------------------------------------------------- 1 | ## func (*Rand) Int63n(n int64) int64 2 | 3 | 参数列表 4 | 5 | - n 期望输出随机值的最大限制值 6 | 7 | 返回值: 8 | 9 | - 返回int64 10 | 11 | 功能说明: 12 | 13 | 14 | 返回一个[0,n)之间的非负伪随机整数.如果n<=0会panic. 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "math/rand" 23 | ) 24 | 25 | func main() { 26 | n := 10 27 | i := 0 28 | r := rand.New(rand.NewSource(64)) 29 | for i < n { 30 | x := r.Int63n(5) 31 | fmt.Println(x) 32 | i += 1 33 | } 34 | } 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /math/rand/Rand-Intn.md: -------------------------------------------------------------------------------- 1 | ## func (*Rand) Intn(n int) int 2 | 3 | 参数列表 4 | 5 | - n 期望输出随机值的最大限制值 6 | 7 | 返回值: 8 | 9 | - 返回int 10 | 11 | 功能说明: 12 | 13 | 14 | 返回一个[0,n)之间的非负伪随机整数.如果n<=0会panic. 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "math/rand" 23 | ) 24 | 25 | func main() { 26 | n := 10 27 | i := 0 28 | r := rand.New(rand.NewSource(64)) 29 | for i < n { 30 | x := r.Intn(5) 31 | fmt.Println(x) 32 | i += 1 33 | } 34 | } 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /math/rand/Rand-Perm.md: -------------------------------------------------------------------------------- 1 | ## func (*Rand) Perm(n int) []int 2 | 3 | 参数列表 4 | 5 | - n 期望输出随机值的最大限制值 6 | 7 | 返回值: 8 | 9 | - 返回[]int 10 | 11 | 功能说明: 12 | 13 | 返回一个元素个数是n的slice,里面的元素是0到n-1的整数无重复的随机排列. 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "math/rand" 22 | ) 23 | 24 | func main() { 25 | n := 10 26 | i := 0 27 | r := rand.New(rand.NewSource(64)) 28 | for i < n { 29 | x := r.Perm(10) 30 | fmt.Println(x) 31 | i += 1 32 | } 33 | } 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /math/rand/Rand-Uint32.md: -------------------------------------------------------------------------------- 1 | ## func (*Rand) Uint32() uint32 2 | 3 | 返回值: 4 | 5 | - 返回int32 6 | 7 | 功能说明: 8 | 9 | 10 | 这个函数主要实现返回一个0-2^32范围内的伪随机数. 11 | 12 | 13 | 代码实例: 14 | 15 | package main 16 | 17 | import ( 18 | "fmt" 19 | "math/rand" 20 | ) 21 | 22 | func main() { 23 | n := 10 24 | i := 0 25 | r := rand.New(rand.NewSource(64)) 26 | for i < n { 27 | x := r.Uint32() 28 | fmt.Println(x) 29 | i += 1 30 | } 31 | } 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /math/rand/Rand.md: -------------------------------------------------------------------------------- 1 | ## type Rand 2 | 3 | 这个是随机数的来源结构体. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /math/rand/Source.md: -------------------------------------------------------------------------------- 1 | ## type Source interface { 2 | ## Int63() int64 3 | ## Seed(seed int64) 4 | ## } 5 | 6 | 7 | Source 结构体是0到2^63-1之间的均匀分布的伪随机数的来源. 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /math/rand/Uint32.md: -------------------------------------------------------------------------------- 1 | ## func Uint32() uint32 2 | 3 | 返回值: 4 | 5 | - 返回int32 6 | 7 | 功能说明: 8 | 9 | 10 | 这个函数主要实现返回一个0-2^32范围内的伪随机数. 11 | 12 | 13 | 代码实例: 14 | 15 | package main 16 | 17 | import ( 18 | "fmt" 19 | "math/rand" 20 | ) 21 | 22 | func main() { 23 | n := 10 24 | i := 0 25 | for i < n { 26 | x := rand.Uint32() 27 | fmt.Println(x) 28 | i += 1 29 | } 30 | } 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /math/rand/Zipf-Uint64.md: -------------------------------------------------------------------------------- 1 | ## func (*Zipf) Uint64 uint64 2 | 3 | 4 | 返回值: 5 | 6 | - unit64 7 | 8 | 功能说明: 9 | 10 | 该函数返回一个按照Zipf对象表述的Zipf分布的值. 11 | 12 | 13 | 代码实例: 14 | 15 | package main 16 | 17 | import ( 18 | "fmt" 19 | "math/rand" 20 | "time" 21 | ) 22 | 23 | func main() { 24 | n := 10 25 | i := 0 26 | 27 | r := rand.New(rand.NewSource(time.Now().UnixNano())) 28 | zipf := rand.NewZipf(r, 3.14, 2.72, 5000) 29 | for i < n { 30 | fmt.Println(zipf.Uint64()) 31 | i += 1 32 | } 33 | } 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /math/rand/Zipf.md: -------------------------------------------------------------------------------- 1 | ## type Zipf struct { 2 | ## // contains filtered or unexported fields 3 | ## } 4 | 5 | 6 | Zipf 是一个产生Zipf分布变量的结构体. 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /mime/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /mime/multipart/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /net/Addr.md: -------------------------------------------------------------------------------- 1 | ## 类型 Addr 2 | 3 | Addr是一个接口,代表一个网络端的地址 4 | 5 | 结构: 6 | 7 | type Addr interface { 8 | Network() string // 网络名字符串 9 | String() string // 地址字符串 10 | } 11 | -------------------------------------------------------------------------------- /net/AddrError.md: -------------------------------------------------------------------------------- 1 | ## 类型 AddrError 2 | 3 | Addr 错误结构 - 请参考 Error包 4 | 5 | 结构: 6 | 7 | type AddrError struct { 8 | Err string 9 | Addr string 10 | } 11 | 12 | 13 | - func (*AddrError) Error 14 | 15 | - func (*AddrError) Temporary 16 | 17 | - func (*AddrError) Timeout 18 | 19 | 20 | -------------------------------------------------------------------------------- /net/CIDRMask.md: -------------------------------------------------------------------------------- 1 | ## func CIDRMask(ones, bits int) IPMask 2 | 3 | 参数列表: 4 | 5 | - ones 网络字符串 6 | - bits 服务名 7 | 8 | 返回列表: 9 | 10 | - IPMask 掩码结构 11 | 12 | [百度百科 - CIDR](http://baike.baidu.com/view/4217886.htm) 13 | 14 | 返回CIDR规范的掩码 15 | ones 必须 大于0 小于 bits 16 | bits 必须为 4(IPv4的字节数)或16(IPv6的字节数)的8倍 17 | 18 | 19 | 代码实例: 20 | 21 | package main 22 | 23 | import "fmt" 24 | import "net" 25 | 26 | func main() { 27 | mask := net.CIDRMask(2,32) 28 | fmt.Printf("%#V",mask) //返回 %!V(net.IPMask=[192 0 0 0]) 29 | } 30 | -------------------------------------------------------------------------------- /net/DNSConfigError.md: -------------------------------------------------------------------------------- 1 | ## 结构 DNSConfigError 2 | 3 | DNSConfigError 错误结构 - 请参考 Error包 4 | 5 | 结构: 6 | 7 | type DNSConfigError struct { 8 | Err error 9 | } 10 | 11 | 12 | - func (*DNSConfigError) Error 13 | 14 | - func (*DNSConfigError) Temporary 15 | 16 | - func (*DNSConfigError) Timeout 17 | 18 | -------------------------------------------------------------------------------- /net/DNSError.md: -------------------------------------------------------------------------------- 1 | ## 结构 DNSError 2 | 3 | DNSError 错误结构 - 请参考 Error包 4 | 5 | 结构: 6 | 7 | type DNSError struct { 8 | Err string // 错误说明 9 | Name string // 错误名 10 | Server string // 使用的服务名 11 | IsTimeout bool // 是否超时 12 | } 13 | 14 | 15 | - func (*DNSError) Error 16 | 17 | - func (*DNSError) Temporary 18 | 19 | - func (*DNSError) Timeout 20 | 21 | -------------------------------------------------------------------------------- /net/Error.md: -------------------------------------------------------------------------------- 1 | ## 接口 Error 2 | 3 | 网络错误接口 4 | 5 | type Error interface { 6 | error 7 | Timeout() bool // 是否属于一个超时错误 8 | Temporary() bool // 是否是一个临时错误 9 | } 10 | -------------------------------------------------------------------------------- /net/FileListener.md: -------------------------------------------------------------------------------- 1 | ## func FileListener(f *os.File) (l Listener, err error) 2 | 3 | 参数列表: 4 | 5 | - f 文件名 6 | 7 | 返回列表: 8 | 9 | - l 监听者 10 | - err 错误 11 | 12 | 打开一个文件,并负责他的关闭,返回一个监听者或者错误 13 | 14 | 代码实例: 15 | 16 | package main 17 | 18 | import "fmt" 19 | import "net" 20 | 21 | func main() { 22 | port,err := net.LookupPort("tcp","https") 23 | if err != nil { 24 | fmt.Println(err) 25 | } 26 | fmt.Println(port) //返回 443 27 | } -------------------------------------------------------------------------------- /net/Flags.md: -------------------------------------------------------------------------------- 1 | ## 结构 Flags 2 | 3 | type Flags uint 4 | 5 | const ( 6 | FlagUp Flags = 1 << iota // 连接接口标志 7 | FlagBroadcast // 广播连接接口标志 8 | FlagLoopback // 环回连接接口标志 9 | FlagPointToPoint //点对点连接接口标志 10 | FlagMulticast // 多播连接接口标志 11 | ) 12 | 13 | 14 | - func (f Flags) String() string 15 | 16 | 返回接口标志 -------------------------------------------------------------------------------- /net/HardwareAddr.md: -------------------------------------------------------------------------------- 1 | ## HardwareAddr 结构 2 | 3 | type HardwareAddr []byte 4 | 5 | 物理硬件地址 6 | 7 | ==== 8 | - func (a HardwareAddr) String() string 9 | 10 | 返回 物理硬件地址的字符串 -------------------------------------------------------------------------------- /net/IPAddr.md: -------------------------------------------------------------------------------- 1 | ## 结构 IPAddr 2 | 3 | type IPAddr struct { 4 | IP IP 5 | } 6 | 7 | IP地址结构 8 | 9 | ==== 10 | - func (a *IPAddr) Network() string 11 | 12 | 返回该ip地址的网络类型名称 13 | 14 | ==== 15 | - func (a *IPAddr) String() string 16 | 17 | 返回该ip地址下的字符串形式IP 18 | 19 | -------------------------------------------------------------------------------- /net/IPMask.md: -------------------------------------------------------------------------------- 1 | ## 结构 IPMask 2 | 3 | type IPMask []byte 4 | 5 | IP掩码结构 6 | 7 | ==== 8 | 9 | - func (m IPMask) Size() (ones, bits int) 10 | 11 | 返回在同一网段内该掩码下能支持多少个IP 12 | 13 | ==== 14 | - func (m IPMask) String() string 15 | 16 | 返回 掩码的字符串形式 17 | -------------------------------------------------------------------------------- /net/IPNet.md: -------------------------------------------------------------------------------- 1 | ## 结构 IPNet 2 | 3 | type IPNet struct { 4 | IP IP // network number 5 | Mask IPMask // network mask 6 | } 7 | 8 | IPNet 结构 9 | 10 | ==== 11 | - func (n *IPNet) Contains(ip IP) bool 12 | 13 | 返回此IP网络是否包含该IP 14 | 15 | ==== 16 | - func (n *IPNet) Network() string 17 | 18 | 返回此IP网络名称 "ip+net" 19 | 20 | ==== 21 | - func (n *IPNet) String() string 22 | 23 | 返回IP网络的字符串形式 -------------------------------------------------------------------------------- /net/IPv4.md: -------------------------------------------------------------------------------- 1 | ## func IPv4(a, b, c, d byte) IP 2 | 3 | 参数列表: 4 | 5 | - a IP地址的第1个字节 6 | - b IP地址的第2个字节 7 | - c IP地址的第3个字节 8 | - d IP地址的第4个字节 9 | 10 | 返回列表: 11 | 12 | - IP ip结构 13 | 14 | 函数功能: 15 | 16 | - 根据a,b,c,d四个字节返回ip结构 17 | 18 | 代码实例: 19 | 20 | package main 21 | 22 | import "fmt" 23 | import "net" 24 | 25 | func main() { 26 | ip := net.IPv4(127,0,1,1) 27 | fmt.Println(ip) 28 | } 29 | 30 | 代码输出: 31 | 32 | 127.0.1.1 33 | -------------------------------------------------------------------------------- /net/IPv4Mask.md: -------------------------------------------------------------------------------- 1 | ## func IPv4Mask(a, b, c, d byte) IPMask 2 | 3 | 参数列表: 4 | 5 | - a IP掩码的第1个字节 6 | - b IP掩码的第2个字节 7 | - c IP掩码的第3个字节 8 | - d IP掩码的第4个字节 9 | 10 | 返回列表: 11 | 12 | - IPMask 掩码 13 | 14 | 函数功能 15 | 16 | - 生成IP掩码 17 | 18 | 代码实例: 19 | 20 | package main 21 | 22 | import "fmt" 23 | import "net" 24 | 25 | func main() { 26 | mask := net.IPv4Mask(127, 127, 127, 127) 27 | fmt.Printf("%#v",mask) 28 | } 29 | 30 | 代码输出: 31 | 32 | net.IPMask{0x7f, 0x7f, 0x7f, 0x7f} -------------------------------------------------------------------------------- /net/InterfaceAddrs.md: -------------------------------------------------------------------------------- 1 | ## func InterfaceAddrs() ([]Addr, error) 2 | 3 | 参数列表: 4 | 5 | - 无 6 | 7 | 返回列表: 8 | 9 | - []Addr 网络地址列表 10 | - error 错误信息 11 | 12 | 返回系统网络地址列表,和错误. 13 | 14 | 代码实例: 15 | 16 | package main 17 | 18 | import "fmt" 19 | import "net" 20 | 21 | func main() { 22 | addrs,err := net.InterfaceAddrs() 23 | if err != nil { 24 | fmt.Println("error") 25 | } 26 | fmt.Println(addrs) // 打印结果应该类似 [127.0.0.1/8 10.200.54.178/20 42.121.14.243/22] 27 | } 28 | -------------------------------------------------------------------------------- /net/InterfaceByIndex.md: -------------------------------------------------------------------------------- 1 | ## func InterfaceByIndex(index int) (*Interface, error) 2 | 3 | 参数列表: 4 | 5 | - index 索引号 6 | 7 | 返回列表: 8 | 9 | - I*nterface 接口结构指针 10 | - error 错误信息 11 | 12 | 根据索引查找网络接口 13 | 14 | 代码实例: 15 | 16 | package main 17 | 18 | import "fmt" 19 | import "net" 20 | 21 | func main() { 22 | interf,err := net.InterfaceByIndex(1) 23 | if err != nil { 24 | fmt.Println(err) 25 | } 26 | fmt.Println(interf) //返回 &{1 16436 lo up|loopback} 27 | } -------------------------------------------------------------------------------- /net/InterfaceByName.md: -------------------------------------------------------------------------------- 1 | ## func InterfaceByName(name string) (*Interface, error) 2 | 3 | 参数列表: 4 | 5 | - name 网络接口名称 6 | 7 | 返回列表: 8 | 9 | - I*nterface 接口结构指针 10 | - error 错误信息 11 | 12 | 根据索引查找网络接口 13 | 14 | 代码实例: 15 | 16 | package main 17 | 18 | import "fmt" 19 | import "net" 20 | 21 | func main() { 22 | interf,err := net.InterfaceByName("eth0") 23 | if err != nil { 24 | fmt.Println(err) 25 | } 26 | fmt.Println(interf) //返回 &{2 1500 eth0 00:16:3e:01:04:1f up|broadcast|multicast} 27 | } -------------------------------------------------------------------------------- /net/Interfaces.md: -------------------------------------------------------------------------------- 1 | ## func Interfaces() ([]Interface, error) 2 | 3 | 参数列表 4 | - 无 5 | 6 | 返回列表 7 | - []Interface 系统网络设备信息列表 8 | - error 错误信息 9 | 10 | 返回系统网络设备信息列表 11 | 12 | 实例: 13 | 14 | package main 15 | 16 | import "fmt" 17 | import "net" 18 | 19 | func main() { 20 | eths,err := net.Interfaces() 21 | if err != nil { 22 | fmt.Println("error") 23 | } 24 | fmt.Println(eths) // 打印结果应该类似[{1 16436 lo up|loopback} {2 1500 eth0 00:16:3e:01:04:1f up|broadcast|multicast} {3 1500 eth1 00:16:3e:01:04:1e up|broadcast|multicast} 25 | } -------------------------------------------------------------------------------- /net/InvalidAddrError.md: -------------------------------------------------------------------------------- 1 | ## 结构 InvalidAddrError 2 | 3 | type InvalidAddrError string 4 | 5 | 非法地址错误,请查看Error包 6 | 7 | ==== 8 | - func (e InvalidAddrError) Error() string 9 | 10 | - func (e InvalidAddrError) Temporary() bool 11 | 12 | - func (e InvalidAddrError) Timeout() bool 13 | 14 | -------------------------------------------------------------------------------- /net/LookupAddr.md: -------------------------------------------------------------------------------- 1 | ## func LookupAddr(addr string) (name []string, err error) 2 | 3 | 参数列表 4 | 5 | - addr 地址字符串 6 | 7 | 返回列表 8 | 9 | - name 主机名列表 10 | - err 错误信息 11 | 12 | 功能说明 13 | 14 | - 通过IP地址查询域名列表 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import "fmt" 21 | import "net" 22 | 23 | func main() { 24 | names := net.LookupAddr("173.194.127.81") 25 | fmt.Println(addr) 26 | } 27 | 28 | 代码输出: 29 | 30 | [hkg03s11-in-f17.1e100.net.] 31 | -------------------------------------------------------------------------------- /net/LookupHost.md: -------------------------------------------------------------------------------- 1 | ## func LookupHost(host string) (addrs []string, err error) 2 | 3 | 参数列表: 4 | 5 | - host 服务器字符串 6 | 7 | 返回列表: 8 | 9 | - 地址列表 10 | - err 错误信息 11 | 12 | 返回该域名的所有地址字符串列表 13 | 14 | 代码实例: 15 | 16 | package main 17 | 18 | import "fmt" 19 | import "net" 20 | 21 | func main() { 22 | addrs,err := net.LookupHost("www.163.com") 23 | if err != nil { 24 | fmt.Println(err) 25 | } 26 | fmt.Println(addrs) // 打印结果应该类似 [122.228.218.179 183.129.198.96] 27 | } -------------------------------------------------------------------------------- /net/LookupIP.md: -------------------------------------------------------------------------------- 1 | ## func LookupIP(host string) (addrs []IP, err error) 2 | 3 | 参数列表: 4 | 5 | - host 服务器字符串 6 | 7 | 返回列表: 8 | 9 | - ip地址列表 10 | - err 错误信息 11 | 12 | 返回该域名的所有ip地址列表 13 | 14 | 代码实例: 15 | 16 | package main 17 | 18 | import "fmt" 19 | import "net" 20 | 21 | func main() { 22 | addrs,err := net.LookupIP("www.163.com") 23 | if err != nil { 24 | fmt.Println(err) 25 | } 26 | fmt.Println(addrs) // 打印结果应该类似 [122.228.218.179 183.129.198.96] 27 | } 28 | -------------------------------------------------------------------------------- /net/LookupPort.md: -------------------------------------------------------------------------------- 1 | ## func LookupPort(network, service string) (port int, err error) 2 | 3 | 参数列表: 4 | 5 | - network 网络字符串 6 | - service 服务名 7 | 8 | 返回列表: 9 | 10 | - port 端口号 11 | - err 错误信息 12 | 13 | 查找特定网络的端口和服务 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import "fmt" 20 | import "net" 21 | 22 | func main() { 23 | port,err := net.LookupPort("tcp","https") 24 | if err != nil { 25 | fmt.Println(err) 26 | } 27 | fmt.Println(port) //返回 443 28 | } -------------------------------------------------------------------------------- /net/LookupTXT.md: -------------------------------------------------------------------------------- 1 | ## func LookupTXT(name string) (txt []string, err error) 2 | 3 | 参数列表: 4 | 5 | - name 域名 6 | 7 | 返回列表: 8 | 9 | - txt txt记录名 10 | - err 错误信息 11 | 12 | 查找该域名下的txt记录 13 | 14 | [百度百科-TXT记录](http://baike.baidu.com/view/1372987.htm) 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import "fmt" 21 | import "net" 22 | 23 | func main() { 24 | txts,err:=net.LookupTXT("163.com") 25 | if err != nil { 26 | fmt.Println(err) 27 | } 28 | for _,txt := range txts { 29 | fmt.Println(txt) // 返回类似 v=spf1 include:spf.163.com -all 30 | } 31 | } -------------------------------------------------------------------------------- /net/MX.md: -------------------------------------------------------------------------------- 1 | ## 结构 MX 2 | 3 | type MX struct { 4 | Host string 5 | Pref uint16 6 | } 7 | 8 | DNS 的MX记录结构 9 | -------------------------------------------------------------------------------- /net/OpError.md: -------------------------------------------------------------------------------- 1 | ## 结构 OpError 2 | 3 | type OpError struct { 4 | Op string 5 | Net string 6 | Addr Addr 7 | Err error 8 | } 9 | 10 | 请参考Error包 11 | 12 | ==== 13 | - func (*OpError) Error 14 | 15 | - func (e *OpError) Temporary() bool 16 | 17 | - func (e *OpError) Timeout() bool 18 | -------------------------------------------------------------------------------- /net/ResolveIPAddr.md: -------------------------------------------------------------------------------- 1 | ## func ResolveIPAddr(net, addr string) (*IPAddr, error) 2 | 3 | 参数列表: 4 | 5 | - net 网络类型 字符串 6 | - addr 地址 字符串 7 | 8 | 返回列表: 9 | 10 | - IPAddr ip地址指针 11 | - error 错误信息 12 | 13 | 返回网络类型下的ip地址/域名的IPAddr结构指针 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import "fmt" 20 | import "net" 21 | 22 | func main() { 23 | ipaddr,err := net.ResolveIPAddr("tcp","www.163.com") 24 | if err != nil { 25 | fmt.Println(err) 26 | } 27 | fmt.Printf("ipaddr:%#v",ipaddr) //ipaddr:&net.IPAddr{IP:[]byte{0x7a, 0xe4, 0xda, 0xb3}} 28 | } -------------------------------------------------------------------------------- /net/http/ParseHTTPVersion.md: -------------------------------------------------------------------------------- 1 | ## func ParseHTTPVersion(vers string) (major, minor int, ok bool) 2 | 3 | 参数 4 | 5 | - vers 响应的写入器 6 | - r 用户请求 7 | 8 | 返回值 9 | 10 | - major 主版本号 11 | - minor 从版本号 12 | - ok true或者false 13 | 14 | 函数功能 15 | 16 | - 该函数解析一个HTTP 版本字符串. 比如输入"HTTP/1.0" 将会返回 (1, 0, true). 17 | 18 | 例子 19 | package main 20 | 21 | import ( 22 | "fmt" 23 | "net/http" 24 | ) 25 | 26 | func main() { 27 | major, minor, ok := http.ParseHTTPVersion("HTTP/1.0") 28 | fmt.Println(major, minor, ok) 29 | } 30 | 31 | -------------------------------------------------------------------------------- /net/http/ProxyURL.md: -------------------------------------------------------------------------------- 1 | ## func ProxyURL(fixedURL *url.URL) func(*Request) (*url.URL, error) 2 | 3 | 参数列表 4 | 5 | - fixedURL 代理的URL 6 | 7 | 返回值: 8 | 9 | - func(*Request) (*url.URL, error) 返回一个代理函数 10 | 11 | 功能说明: 12 | ProxyURL返回一个代理函数,这个代理函数(一般在Transport中使用)接受请求,并总是返回一个(代理后的)地址。 13 | 14 | 15 | 代码实例 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | ) 22 | 23 | func main() { 24 | fmt.Println("这个函数暂时不知道用在什么地方") 25 | } 26 | 27 | 28 | -------------------------------------------------------------------------------- /net/http/StatusText.md: -------------------------------------------------------------------------------- 1 | ## func StatusText(code int) string 2 | 3 | 参数列表 4 | 5 | - code 状态码 6 | 7 | 返回值: 8 | 9 | - string 对应状态码的字符串 10 | 11 | 功能说明: 12 | 该函数为一个http状态码返回对应的文本。 13 | 如果状态码未知的话,则返回一个空的字符串。 14 | 15 | 代码实例 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "net/http" 22 | ) 23 | 24 | func main() { 25 | fmt.Println(http.StatusText(404)) 26 | fmt.Println(http.StatusText(202)) 27 | } 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /net/http/cgi/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /net/http/fcgi/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /net/http/httptest/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /net/http/httputil/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /net/http/pprof/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /net/mail/ExampleAddress.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net/mail" 5 | "fmt" 6 | ) 7 | 8 | func main() { 9 | addr := mail.Address{"Jim Green", "noreply@noreply.com"} 10 | fmt.Println(addr.String()) 11 | // Output: =?utf-8?q?Jim_Green?= 12 | addr = mail.Address{"中文", "noreply@noreply.com"} 13 | fmt.Println(addr.String()) 14 | // Output: =?utf-8?q?=E4=B8=AD=E6=96=87?= 15 | } 16 | -------------------------------------------------------------------------------- /net/mail/README.md: -------------------------------------------------------------------------------- 1 | # net/mail 2 | 3 | 函数列表 4 | 5 | - 函数列表暂时区分于类型吧 6 | 7 | 类型列表 8 | 9 | - [Address](Address.md) - RFC 5322 地址 10 | - [Header](Header.md) - 邮件头的 Golang 表示 11 | - [Message](Message.md) - 邮件消息的 Golang 表示 12 | 13 | by: andelf 14 | -------------------------------------------------------------------------------- /net/rpc/jsonrpc/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /net/smtp/Client.md: -------------------------------------------------------------------------------- 1 | ## type Client 2 | 3 | Client 用于和 smtp 服务器建立连接. 代码例子请参考 [Auth](Auth.md). 4 | -------------------------------------------------------------------------------- /net/smtp/README.md: -------------------------------------------------------------------------------- 1 | # net/smtp 2 | 3 | RFC 5321 (SMTP, Simple Mail Transfer Protocol, 简单邮件传输协议) 的 Golang 实现。想发邮件,你就找对了。 4 | 5 | 类型列表 6 | 7 | - [Auth](Auth.md) - smtp 用户认证方法 8 | - [Client](Client.md) - smtp 客户端实现 9 | - ServerInfo 10 | 11 | ServerInfo 只用于传参, 为简单 struct, 没有成员函数. 12 | 13 | 函数列表 14 | 15 | - func [SendMail](SendMail.md)(addr string, a Auth, from string, to []string, msg []byte) error 16 | 17 | 一般简单的发送邮件任务请直接是用 SendMail() 函数. 18 | -------------------------------------------------------------------------------- /net/textproto/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /net/url/QueryEscape.md: -------------------------------------------------------------------------------- 1 | #func QueryEscape(s string) string 2 | 3 | [参数列表]: 4 | 5 | - s 表示需要参数(字符串) 6 | 7 | [返回值]: 8 | 9 | -返回值为:转义字符串 10 | 11 | [功能说明]: 12 | 13 | escapes the string so it can be safely placed inside a URL query. 14 | 15 | 逃避查询,因此它可以被安全的放置在URL查询字符串。请参阅RFC 3986。 16 | 17 | [代码实例]: 18 | 19 | package main 20 | import ( 21 | "fmt" 22 | "net/url" 23 | ) 24 | 25 | func main() { 26 | sUrl := url.QueryEscape("http://www.golang.org") 27 | fmt.Println(sUrl) 28 | } 29 | //输出结果:http%3A%2F%2Fwww.golang.org 30 | 31 | -------------------------------------------------------------------------------- /net/url/QueryUnescape.md: -------------------------------------------------------------------------------- 1 | #func QueryUnescape(s string) (string, error) 2 | 3 | [参数列表]: 4 | 5 | - s 表示需要参数(字符串) 6 | 7 | [返回值]: 8 | 9 | -返回值为:字符串,错误信息 10 | 11 | [功能说明]: 12 | 对QueryEscape函数转换的值进行逆转。如果%后没有包含两个十六进制数,它将返回一个错语 13 | 14 | [代码实例]: 15 | 16 | package main 17 | import ( 18 | "fmt" 19 | "net/url" 20 | ) 21 | 22 | func main() { 23 | uUrl,err := url.QueryUnescape("http%3A%2F%2Fwww.golang.org") 24 | if err == nil { 25 | fmt.Printf(uUrl) 26 | }else{ 27 | fmt.Println(err) 28 | } 29 | } 30 | //输出结果:http://www.golang.org 31 | 32 | -------------------------------------------------------------------------------- /net/url/README.md: -------------------------------------------------------------------------------- 1 | # 包名:net/url 2 | # 概术: 3 | Package url parses URLs and implements query escaping. 4 | # 函数列表 5 | - [func QueryEscape(s string) string](QueryEscape.md) 6 | - [func QueryUnescape(s string) (string, error)](QueryUnescape.md) 7 | - func Parse(rawurl string) (url *URL, err error) 8 | - func ParseRequestURI(rawurl string) (url *URL, err error) 9 | - func User(username string) *Userinfo 10 | - func UserPassword(username, password string) *Userinfo 11 | - func ParseQuery(query string) (m Values, err error) 12 | -------------------------------------------------------------------------------- /os/Environ.md: -------------------------------------------------------------------------------- 1 | ## func Environ() []string 2 | 3 | 参数列表 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - []string 环境变量 10 | 11 | 功能说明: 12 | 13 | 这个函数主要是获取当前环境变量 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "os" 22 | ) 23 | 24 | func main() { 25 | fmt.Printf("The path is: %+v\n", os.Environ()) 26 | } 27 | 28 | 代码输出: 29 | 30 | //test in ArchLinux 31 | //只放了一部分结果 32 | The path is: [USER=miraclesu LG_ALL=zh_CN.UTF-8] 33 | -------------------------------------------------------------------------------- /os/Getegid.md: -------------------------------------------------------------------------------- 1 | ## func Getegid() int 2 | 3 | 参数列表 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - int 调用者的有效用户组id 10 | 11 | 功能说明: 12 | 13 | 这个函数主要是返回调用者的有效用户组id 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "os" 22 | ) 23 | 24 | func main() { 25 | fmt.Printf("%d\n", os.Getegid()) 26 | } 27 | 28 | 代码输出: 29 | 30 | //test in ArchLinux 31 | 100 32 | -------------------------------------------------------------------------------- /os/Getenv.md: -------------------------------------------------------------------------------- 1 | ## func Getenv(key string) string 2 | 3 | 参数列表 4 | 5 | - key 环境变量的key 6 | 7 | 返回值: 8 | 9 | - string 返回环境变量的key对应的值 10 | 11 | 功能说明: 12 | 13 | 这个函数主要是根据key来获取相当环境变量的值 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "os" 22 | ) 23 | 24 | func main() { 25 | fmt.Printf("%s\n", os.Getenv("LANG")) 26 | } 27 | 28 | 代码输出: 29 | 30 | //test in ArchLinux 31 | zh_CN.UTF-8 32 | -------------------------------------------------------------------------------- /os/Geteuid.md: -------------------------------------------------------------------------------- 1 | ## func Geteuid() int 2 | 3 | 参数列表 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - int 调用者的有效用户id 10 | 11 | 功能说明: 12 | 13 | 这个函数主要是返回调用者的有效用户id 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "os" 22 | ) 23 | 24 | func main() { 25 | fmt.Printf("%d\n", os.Geteuid()) 26 | } 27 | 28 | 代码输出: 29 | 30 | //test in ArchLinux 31 | 1000 32 | -------------------------------------------------------------------------------- /os/Getgid.md: -------------------------------------------------------------------------------- 1 | ## func Getgid() int 2 | 3 | 参数列表 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - int 调用者的用户组id 10 | 11 | 功能说明: 12 | 13 | 这个函数主要是返回调用者的用户组id 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "os" 22 | ) 23 | 24 | func main() { 25 | fmt.Printf("%d\n", os.Getgid()) 26 | } 27 | 28 | 代码输出: 29 | 30 | //test in ArchLinux 31 | 100 32 | -------------------------------------------------------------------------------- /os/Getpagesize.md: -------------------------------------------------------------------------------- 1 | ## func Getpagesize() int 2 | 3 | 参数列表 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - int 返回系统内在的大小,单位为MB 10 | 11 | 功能说明: 12 | 13 | 这个函数主要是返回系统内存的大小 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "os" 22 | ) 23 | 24 | func main() { 25 | fmt.Printf("%d\n", os.Getpagesize()) 26 | } 27 | 28 | 代码输出: 29 | 30 | //test in ArchLinux 31 | 4096 32 | -------------------------------------------------------------------------------- /os/Getpid.md: -------------------------------------------------------------------------------- 1 | ## func Getpid() int 2 | 3 | 参数列表 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - int 返回调用者进程id 10 | 11 | 功能说明: 12 | 13 | 这个函数主要是返回调用者进程id 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "os" 22 | ) 23 | 24 | func main() { 25 | fmt.Printf("%d\n", os.Getpid()) 26 | } 27 | 28 | 代码输出: 29 | 30 | //test in ArchLinux 31 | //每次执行的结果可能都不一样 32 | 11396 33 | -------------------------------------------------------------------------------- /os/Getppid.md: -------------------------------------------------------------------------------- 1 | ## func Getppid() int 2 | 3 | 参数列表 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - int 返回调用者的父进程id 10 | 11 | 功能说明: 12 | 13 | 这个函数主要是返回调用者的父进程id 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "os" 22 | ) 23 | 24 | func main() { 25 | fmt.Printf("%d\n", os.Getppid()) 26 | } 27 | 28 | 代码输出: 29 | 30 | //test in ArchLinux 31 | //每次执行的结果可能都不一样 32 | 11355 33 | -------------------------------------------------------------------------------- /os/Getuid.md: -------------------------------------------------------------------------------- 1 | ## func Getuid() int 2 | 3 | 参数列表 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - int 调用者的用户id 10 | 11 | 功能说明: 12 | 13 | 这个函数主要是返回调用者的用户id 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "os" 22 | ) 23 | 24 | func main() { 25 | fmt.Printf("%d\n", os.Getuid()) 26 | } 27 | 28 | 代码输出: 29 | 30 | //test in ArchLinux 31 | 1000 32 | -------------------------------------------------------------------------------- /os/IsPathSeparator.md: -------------------------------------------------------------------------------- 1 | ## func IsPathSeparator(c uint8) bool 2 | 3 | 参数列表 4 | 5 | - c 判断字符 6 | 7 | 返回值: 8 | 9 | - bool 是否为目录路径分割符 10 | 11 | 功能说明: 12 | 13 | 这个函数主要是判断一个字符是否为目录路径分割符 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "os" 22 | ) 23 | 24 | func main() { 25 | fmt.Printf("%t\n", os.IsPathSeparator('/')) 26 | fmt.Printf("%t\n", os.IsPathSeparator('.')) 27 | } 28 | 29 | 代码输出: 30 | 31 | //test in ArchLinux 32 | true 33 | false 34 | -------------------------------------------------------------------------------- /os/TempDir.md: -------------------------------------------------------------------------------- 1 | ## func TempDir() string 2 | 3 | 参数列表 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - 返回string 系统的tmp目录 10 | 11 | 功能说明: 12 | 13 | 这个函数主要是获取系统的tmp目录 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "os" 22 | ) 23 | 24 | func main() { 25 | fmt.Printf("The temp dir is: %s\n", os.TempDir()) 26 | } 27 | 28 | 代码输出: 29 | 30 | //test in ArchLinux 31 | The temp dir is: /tmp 32 | -------------------------------------------------------------------------------- /os/signal/Notify.md: -------------------------------------------------------------------------------- 1 | ## func Notify(c chan<- os.Signal, sig ...os.Signal) 2 | 3 | 参数列表 4 | - c 信号 channel 5 | - sig 需要捕获的信号 6 | 7 | 实例: 8 | package main 9 | 10 | import( 11 | "fmt" 12 | "os" 13 | "os/signal" 14 | ) 15 | 16 | func main() { 17 | schan := make(chan os.Signal) 18 | go signal.Notify(schan, os.Interrupt, os.Kill) 19 | fmt.Printf("Signal captured: %d", <-schan) 20 | } 21 | -------------------------------------------------------------------------------- /os/signal/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /os/user/README.md: -------------------------------------------------------------------------------- 1 | # os/user包函数列表 2 | 3 | - [func Current() (*User, error)](Current.md) 4 | - [func Lookup(username string) (*User, error)](Lookup.md) 5 | - [func LookupId(uid string) (*User, error)](LookupId.md) 6 | 7 | -------------------------------------------------------------------------------- /path/Base.md: -------------------------------------------------------------------------------- 1 | ## func Base(path string) string 2 | 3 | 参数列表 4 | 5 | - path 表示需要取路径的字符串 6 | 7 | 8 | 返回值: 9 | 10 | - 返回string 11 | 12 | 功能说明: 13 | 14 | 这个函数主要是用来返回最后一个元素的路径,如果路径为空返回.如果路径由斜线组成,返回/ 15 | 16 | 代码实例: 17 | ~~~ 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "path" 23 | ) 24 | 25 | func main() { 26 | fmt.Println(path.Base("/a/b")) // b 27 | fmt.Println(path.Base("")) // . 28 | fmt.Println(path.Base("////")) // / 29 | } 30 | ~~~ 31 | -------------------------------------------------------------------------------- /path/Dir.md: -------------------------------------------------------------------------------- 1 | ## func Dir(path string) string 2 | 3 | 参数列表 4 | 5 | - path 表示路径字符串 6 | 7 | 8 | 返回值: 9 | 10 | - 返回string 11 | 12 | 功能说明: 13 | 14 | 这个函数主要是返回path中最后一个元素的路径 15 | - 规则: 16 | - 1.通常是路径最后一个元素的路径目录 17 | - 2.路径为空返回. 18 | 19 | 20 | 21 | 代码实例: 22 | ~~~ 23 | package main 24 | 25 | import ( 26 | "fmt" 27 | "path" 28 | ) 29 | 30 | func main() { 31 | fmt.Println(path.Dir("/a/b/c")) // /a/b 32 | fmt.Println(path.Dir("")) // . 33 | } 34 | 35 | ~~~ -------------------------------------------------------------------------------- /path/Ext.md: -------------------------------------------------------------------------------- 1 | ## func Ext(path string) string 2 | 3 | 参数列表 4 | 5 | - path 表示路径字符串 6 | 7 | 8 | 返回值: 9 | 10 | - 返回string 11 | 12 | 功能说明: 13 | 14 | 这个函数主要是返回path中文件的扩展名 15 | -规则: 16 | - 1.最后一个点开始的扩展名 17 | - 2.如果没有点,返回空 18 | 19 | 20 | 21 | 代码实例: 22 | ~~~ 23 | package main 24 | 25 | import ( 26 | "fmt" 27 | "path" 28 | ) 29 | 30 | func main() { 31 | fmt.Println(path.Ext("/a/b/c/bar.css")) // .css 32 | fmt.Println(path.Ext("/a/b/c/bar")) // "" 33 | } 34 | ~~~ -------------------------------------------------------------------------------- /path/IsAbs.md: -------------------------------------------------------------------------------- 1 | ## func IsAbs(path string) bool 2 | 3 | 参数列表 4 | 5 | - path 表示路径字符串 6 | 7 | 8 | 返回值: 9 | 10 | - 返回bool 11 | 12 | 功能说明: 13 | 14 | 这个函数主要是判断路径是不是绝对路径,如果是绝对路径返回true 15 | 16 | 17 | 18 | 代码实例: 19 | ~~~ 20 | package main 21 | 22 | import ( 23 | "fmt" 24 | "path" 25 | ) 26 | 27 | func main() { 28 | fmt.Println(path.IsAbs("/home/zzz/go.pdf")) // true 29 | fmt.Println(path.IsAbs("home/zzz/go.pdf")) // false 30 | } 31 | ~~~ -------------------------------------------------------------------------------- /path/Join.md: -------------------------------------------------------------------------------- 1 | ## func Join(elem ...string) string 2 | 3 | 参数列表 4 | 5 | - elem 表示要连接的路径 6 | 7 | 8 | 返回值: 9 | 10 | - 返回string 11 | 12 | 功能说明: 13 | 14 | 这个函数主要是连接路径,返回的结果是已经Clean的,如果是空路径就忽略 15 | 16 | 17 | 18 | 代码实例: 19 | ~~~ 20 | package main 21 | 22 | import ( 23 | "fmt" 24 | "path" 25 | ) 26 | 27 | func main() { 28 | fmt.Println(path.Join("a", "b", "c")) // a/b/c 29 | fmt.Println(path.Join("a", "", "c")) // a/c 30 | fmt.Println(path.Join("a", "../bb/../c", "c")) // c/c 31 | } 32 | ~~~ -------------------------------------------------------------------------------- /path/README.md: -------------------------------------------------------------------------------- 1 | # path函数列表 2 | 3 | - [func Base(path string) string](Base.md) 4 | - [func Clean(path string) string](Clean.md) 5 | - [func Dir(path string) string](Dir.md) 6 | - [func Ext(path string) string](Ext.md) 7 | - [func IsAbs(path string) bool](IsAbs.md) 8 | - [func Join(elem ...string) string](Join.md) 9 | - [func Match(pattern, name string) (matched bool, err error)](Match.md) 10 | - [func Split(path string) (dir, file string)](Split.md) 11 | -------------------------------------------------------------------------------- /path/Split.md: -------------------------------------------------------------------------------- 1 | ## func Split(path string) (dir, file string) 2 | 3 | 参数列表 4 | 5 | - path 表示路径字符串 6 | 7 | 8 | 返回值: 9 | 10 | - 返回string,string 11 | 12 | 功能说明: 13 | 14 | 这个函数主要是分离路径中的文件目录和文件 15 | 16 | 17 | 18 | 代码实例: 19 | ~~~ 20 | package main 21 | 22 | import ( 23 | "fmt" 24 | "path" 25 | ) 26 | 27 | func main() { 28 | fmt.Println(path.Split("static/myfile.css")) // static/ myfile.css 29 | fmt.Println(path.Split("static")) // "" static 30 | } 31 | ~~~ -------------------------------------------------------------------------------- /path/filepath/Abs.md: -------------------------------------------------------------------------------- 1 | ## func Abs(path string) (string, error) 2 | 3 | 参数列表: 4 | 5 | - path: 6 | 7 | 返回值列表: 8 | 9 | - 返回所给路径的绝对路径string 10 | - error 11 | 12 | 功能说明: 13 | 14 | 返回所给的路径的的绝对路径。 15 | 16 | 示例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "path/filepath" 23 | ) 24 | 25 | func main(){ 26 | // 当前路径为/home, 如下返回的path将会是/home/abs_demo.go 27 | path, _ := filepath.Abs("abs_demo.go") 28 | fmt.Printf("%v\n", path) 29 | } 30 | 31 | 32 | -------------------------------------------------------------------------------- /path/filepath/Base.md: -------------------------------------------------------------------------------- 1 | 具体用法件 path.Base 2 | -------------------------------------------------------------------------------- /path/filepath/Clean.md: -------------------------------------------------------------------------------- 1 | 具体用法见 path.Clean 2 | -------------------------------------------------------------------------------- /path/filepath/Dir.md: -------------------------------------------------------------------------------- 1 | 具体用法件 path.Dir 2 | -------------------------------------------------------------------------------- /path/filepath/Ext.md: -------------------------------------------------------------------------------- 1 | 具体用法见 path.Ext 2 | -------------------------------------------------------------------------------- /path/filepath/FromSlash.md: -------------------------------------------------------------------------------- 1 | ## func FromSlash(path string) string 2 | 3 | 参数列表: 4 | 5 | - 路径字符串 6 | 7 | 返回值: 8 | 9 | - 返回替换后的字符串。 10 | 11 | 功能说明: 12 | 13 | 将所有的"/"使用路径分隔符替换。分隔符见os.PathSeparator, linux默认的分隔符是"/"。 14 | 15 | 示例: 16 | 17 | -------------------------------------------------------------------------------- /path/filepath/HasPrefix.md: -------------------------------------------------------------------------------- 1 | 具体使用方法见strings.HasPrefix, 该函数是为了兼容以前的版本,不建议使用 2 | -------------------------------------------------------------------------------- /path/filepath/IsAbs.md: -------------------------------------------------------------------------------- 1 | 具体的使用方法件 path.IsAbs 2 | -------------------------------------------------------------------------------- /path/filepath/Join.md: -------------------------------------------------------------------------------- 1 | 具体用法见 path.Join 2 | -------------------------------------------------------------------------------- /path/filepath/Match.md: -------------------------------------------------------------------------------- 1 | 具体的用法见 path.Match 2 | -------------------------------------------------------------------------------- /path/filepath/Split.md: -------------------------------------------------------------------------------- 1 | 具体用法见 path.Split 2 | -------------------------------------------------------------------------------- /path/filepath/SplitList.md: -------------------------------------------------------------------------------- 1 | ## func SplitList(path string) []string 2 | 3 | 参数列表: 4 | 5 | - 路径字符串 6 | 7 | 返回值: 8 | 9 | - 路径列表。 10 | 11 | 功能说明: 12 | 13 | 将路径字符串使用路径列表分隔符分开。路径列表分隔符见os.PathListSeparator, linux的 14 | 路径列表分隔符是":", windows的路径列表分隔符是";",主要用于PATH或是GOPATH等环境变 15 | 量。 16 | 17 | 示例: 18 | 19 | ~~~ 20 | package main 21 | 22 | import ( 23 | "fmt" 24 | "path/filepath" 25 | ) 26 | 27 | func main(){ 28 | fmt.Printf("%v\n", filepath.SplitList("a/b;c/d")) //[a/b; c/d] 29 | } 30 | ~~~ 31 | 32 | -------------------------------------------------------------------------------- /path/filepath/ToSlash.md: -------------------------------------------------------------------------------- 1 | ## func ToSlash(path string) string 2 | 3 | 参数列表: 4 | 5 | - 路径字符串 6 | 7 | 返回值: 8 | 9 | - 返回替换后的字符串。 10 | 11 | 功能说明: 12 | 13 | 将所有的路径分隔符使用"/"替换。分隔符见os.PathSeparator, linux默认的分隔符是"/"。 14 | 15 | 示例: 16 | 17 | -------------------------------------------------------------------------------- /path/filepath/VolumeName.md: -------------------------------------------------------------------------------- 1 | ## func VolumeName(path string) (v string) 2 | 3 | 参数列表 4 | 5 | - path: 路径名 6 | 7 | 返回值列表 8 | 9 | - v: 如果是window平台返回分区名,如给定"c:\foo\bar", 将返回"c:", 如果给定"\\host\share\foo", 返回"\\host\share", 其他平台返回"" 10 | 11 | 功能说明 12 | 13 | windows平台下返回文件的分区名。 14 | -------------------------------------------------------------------------------- /reflect/PtrTo.md: -------------------------------------------------------------------------------- 1 | # func PtrTo(t Type) Type 2 | 3 | 参数列表 4 | 5 | - t Type 是一个反射类型 6 | 7 | 返回值: 8 | 9 | - Type 返回指针类型(reflect.Type) 10 | 11 | 功能说明: 12 | 13 | - PtrTo 返回元素 t 的指针类型。例如,t 表示 Foo 类型,则 PtrTo(T) 代表 *Foo 类型。 14 | 15 | 代码实例: 16 | 17 | package main 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | func main(){ 24 | var a int 25 | var pt reflect.Type = reflect.PtrTo(reflect.TypeOf(a)) 26 | fmt.Println(pt.Kind(), pt.Elem().Kind()) // .Emel() 表示直接寻址 27 | // >>*int int 28 | } 29 | -------------------------------------------------------------------------------- /reflect/SliceOf.md: -------------------------------------------------------------------------------- 1 | # func SliceOf(t Type) Type 2 | 参数列表 3 | 4 | - t Type 切片的类型,如[]int,传入int的反射类型。 5 | 6 | 返回值: 7 | 8 | - Type 返回 reflect.Type 类型,更多方法可以查看reflect.Type 接口 9 | 10 | 功能说明: 11 | 12 | - SliceOf 返回t元素类型的一个切片 。例如,如果t表示整型(int),SliceOf(t)就是表示[]int。 13 | 14 | 代码实例: 15 | 16 | package main 17 | import ( 18 | "fmt" 19 | "reflect" 20 | ) 21 | 22 | func main(){ 23 | var i int 24 | var sliceOf reflect.Type = reflect.SliceOf(reflect.TypeOf(i)) 25 | fmt.Println(sliceOf.Kind(), sliceOf.String()) 26 | //slice []int 27 | } 28 | -------------------------------------------------------------------------------- /reflect/Type.Key.md: -------------------------------------------------------------------------------- 1 | # Key() Type 2 | 3 | 参数列表 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - Type reflect.Type 返回 map 类型 key 的类型。 10 | 11 | 功能说明: 12 | 13 | - reflect.TypeOf(interface{}).Key() 返回 map 类型 key 的类型。如果出现恐慌(panic),表示变量类型不是Map。 14 | 15 | 代码实例: 16 | 17 | package main 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | func main(){ 24 | var a map[int]string 25 | var typeA reflect.Type = reflect.TypeOf(a) 26 | fmt.Println(typeA.Key(), typeA.Elem().Kind()) 27 | //>>int string 28 | } 29 | -------------------------------------------------------------------------------- /reflect/Type.Kind.md: -------------------------------------------------------------------------------- 1 | # Kind() Kind 2 | 3 | 参数列表 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - Kind 返回特定的 reflect.Kind 类型 10 | 11 | 功能说明: 12 | 13 | - reflect.TypeOf(interface{}).Kind() 返回特定的 Kind 类型。 14 | 15 | 代码实例: 16 | 17 | package main 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | func main(){ 24 | var a int 25 | var typeof reflect.Type = reflect.TypeOf(a) 26 | fmt.Println(typeof.Kind(), typeof.Kind() == reflect.Int) 27 | //>>int true 28 | } 29 | -------------------------------------------------------------------------------- /reflect/Type.Len.md: -------------------------------------------------------------------------------- 1 | # Len() int 2 | 3 | 参数列表 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - int 返回数组Array的长度 10 | 11 | 功能说明: 12 | 13 | - reflect.TypeOf(interface{}).Len() 返回数组Array的长度。如果出现恐慌(panic),表示变量类型不是Array。 14 | 15 | 代码实例: 16 | 17 | package main 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | func main(){ 24 | var a [33]int 25 | var typeA reflect.Type = reflect.TypeOf(a) 26 | fmt.Println(typeA.Len()) 27 | //>>33 28 | } 29 | -------------------------------------------------------------------------------- /reflect/Type.Name.md: -------------------------------------------------------------------------------- 1 | # Name() string 2 | 3 | 参数列表 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - string 类型的名字 10 | 11 | 功能说明: 12 | 13 | - reflect.TypeOf(interface{}).Name() 返回类型的名字 14 | 15 | 代码实例: 16 | 17 | package main 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | func main(){ 24 | var a int 25 | var typeof reflect.Type = reflect.TypeOf(a) 26 | fmt.Println(typeof.Name()) 27 | //>>int 28 | } 29 | -------------------------------------------------------------------------------- /reflect/Type.NumField.md: -------------------------------------------------------------------------------- 1 | # NumField() int 2 | 3 | 参数列表 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - int 字段总数量 10 | 11 | 功能说明: 12 | 13 | - reflect.TypeOf(interface{}).NumField() 返回struct结构中的字段总数量 14 | 15 | 代码实例: 16 | 17 | package main 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | type A struct { 24 | A0 int 25 | A1 string 26 | A2 []byte 27 | } 28 | 29 | func main(){ 30 | var a A 31 | var typeof reflect.Type = reflect.TypeOf(a) 32 | fmt.Println(typeof.NumField()) 33 | //>>3 34 | } 35 | -------------------------------------------------------------------------------- /reflect/Type.NumIn.md: -------------------------------------------------------------------------------- 1 | # NumIn() int 2 | 3 | 参数列表 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - int 函数传入参数的总数量 10 | 11 | 功能说明: 12 | 13 | - reflect.TypeOf(interface{}).NumIn() 函数传入参数的总数量,如果出现恐慌(panic),该类型不是 Func。 14 | 15 | 代码实例: 16 | 17 | package main 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | func main(){ 24 | var a = func(a1 int, a2 string, a3 uint, a4 interface{}) {} 25 | var typeof reflect.Type = reflect.TypeOf(a) 26 | fmt.Println(typeof.NumIn()) 27 | //>>4 28 | } 29 | -------------------------------------------------------------------------------- /reflect/Type.NumMethod.md: -------------------------------------------------------------------------------- 1 | # NumMethod() int 2 | 3 | 参数列表 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - int 返回函数的总数量 10 | 11 | 功能说明: 12 | 13 | - reflect.TypeOf(x).NumMethod() 返回struct结构绑定的方法集。 14 | 15 | 代码实例: 16 | 17 | package main 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | type A struct { 24 | A0 int 25 | } 26 | func (f A) test(){} 27 | func (f A) test1(){} 28 | func (f A) test2(){} 29 | 30 | func main(){ 31 | var a A 32 | var typeof reflect.Type = reflect.TypeOf(a) 33 | fmt.Println(typeof.NumMethod()) 34 | //>>3 35 | } 36 | -------------------------------------------------------------------------------- /reflect/Type.NumOut.md: -------------------------------------------------------------------------------- 1 | # NumOut() int 2 | 3 | 参数列表 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - int 函数输出参数总数量 10 | 11 | 功能说明: 12 | 13 | - reflect.TypeOf(interface{}).NumOut() 一个函数的输出参数总数量。如果出现恐慌(panic),表示该类型不是Func。 14 | 15 | 代码实例: 16 | 17 | package main 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | func main(){ 24 | var a = func() (int, string, uint, float64) { 25 | return 1, "1", 2, 1.2 26 | } 27 | var typeof reflect.Type = reflect.TypeOf(a) 28 | fmt.Println(typeof.NumOut()) 29 | //>>4 30 | } 31 | -------------------------------------------------------------------------------- /reflect/Type.Size.md: -------------------------------------------------------------------------------- 1 | # Size() uintptr 2 | 3 | 参数列表 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - uintptr 数据的字节数 10 | 11 | 功能说明: 12 | 13 | - reflect.TypeOf(interface{}).Size() 返回值存储的字节数,是类似 unsafe.Sizeof。 14 | 15 | 代码实例: 16 | 17 | package main 18 | import ( 19 | "fmt" 20 | "reflect" 21 | "unsafe" 22 | ) 23 | 24 | func main(){ 25 | var a int 26 | a = 1234 27 | var typeof reflect.Type = reflect.TypeOf(a) 28 | fmt.Println(typeof.Size(), unsafe.Sizeof(a)) //这两个功能是等介的 29 | //>>4 4 30 | } 31 | -------------------------------------------------------------------------------- /reflect/Type.String.md: -------------------------------------------------------------------------------- 1 | # String() string 2 | 3 | 参数列表 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - string 字符串表示的类型 10 | 11 | 功能说明: 12 | 13 | - reflect.TypeOf(interface{}).String() 返回一个字符串表示的类型 14 | 15 | 代码实例: 16 | 17 | package main 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | func main(){ 24 | var a int 25 | var typeof reflect.Type = reflect.TypeOf(a) 26 | fmt.Println(typeof.String()) 27 | //>>int 28 | } 29 | -------------------------------------------------------------------------------- /reflect/TypeOf.md: -------------------------------------------------------------------------------- 1 | # func TypeOf(i interface{}) Type 2 | 3 | 参数列表 4 | 5 | - i interface{} 是一个接口类型,可以传入任何类型变量 6 | 7 | 返回值: 8 | 9 | - Type 返回反射类型 reflect.Type 10 | 11 | 功能说明: 12 | 13 | - TypeOf 返回interface{}接口的值反射它的类型。 TypeOf(nil) 返回nil。 14 | 15 | 代码实例: 16 | 17 | package main 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | func main(){ 24 | var a int 25 | var typeof reflect.Type = reflect.TypeOf(a) 26 | fmt.Println(typeof.String()) 27 | //>>int 28 | } 29 | -------------------------------------------------------------------------------- /reflect/Value.CanAddr.md: -------------------------------------------------------------------------------- 1 | # func (v Value) CanAddr() bool 2 | 3 | 参数列表 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - bool 如果该值的地址可以得到寻址, 返回true。否则返回false。 10 | 11 | 功能说明: 12 | 13 | - reflect.ValueOf(interface{}).CanAddr() 如果该值的地址可以得到寻址,返回true。这样的值被称为寻址。如果元素它是一个切片,值是可寻址的。 14 | 15 | 代码实例: 16 | 17 | package main 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | func main(){ 24 | var a int 25 | var value reflect.Value = reflect.ValueOf(&a) 26 | fmt.Println(value.CanAddr(), value.Elem().CanAddr()) 27 | //>>false true 28 | } 29 | -------------------------------------------------------------------------------- /reflect/Value.Elem.md: -------------------------------------------------------------------------------- 1 | # func (v Value) Elem() Value 2 | 3 | 参数列表 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - Value 返回一个直接指向内存地址的 reflect.Value 类型 10 | 11 | 功能说明: 12 | 13 | - reflect.ValueOf(interface{}).Elem() 将指针地址指向内存地址,如果出现恐慌(panic),表示该类型不是 Ptr 14 | 15 | 代码实例: 16 | 17 | package main 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | func main(){ 24 | var a int 25 | var value reflect.Value = reflect.ValueOf(&a) 26 | fmt.Println(value.Kind(), value.Elem().Kind()) 27 | //>>ptr int 28 | } 29 | -------------------------------------------------------------------------------- /reflect/Value.Pointer.md: -------------------------------------------------------------------------------- 1 | # func (v Value) Pointer() uintptr 2 | 3 | 参数列表 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - uintptr 返回指针值(整数) 10 | 11 | 功能说明: 12 | 13 | - reflect.ValueOf(interface{}).Pointer() 返回 v 的指针值(uintptr) 14 | 15 | 代码实例: 16 | 17 | package main 18 | import ( 19 | "fmt" 20 | "reflect" 21 | "unsafe" 22 | ) 23 | 24 | func main(){ 25 | var a complex64 26 | var value reflect.Value = reflect.ValueOf(&a) 27 | fmt.Println(value.Pointer(), uintptr(unsafe.Pointer(&a))) 28 | } 29 | -------------------------------------------------------------------------------- /reflect/Value.UnsafeAddr.md: -------------------------------------------------------------------------------- 1 | # func (v Value) UnsafeAddr() uintptr 2 | 3 | 参数列表 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - uintptr 返回指针(整数) 10 | 11 | 功能说明: 12 | 13 | - reflect.ValueOf(interface{}).UnsafeAddr() 返回一个指针指向v的数据。如果v是不可寻址,会出现恐慌(panic)。 14 | 15 | 代码实例: 16 | 17 | package main 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | func main(){ 24 | var a int 25 | var value reflect.Value = reflect.ValueOf(&a) 26 | fmt.Println(value.Elem().UnsafeAddr(), uintptr(unsafe.Pointer(&a))) 27 | //>>282918960 282918960 28 | } 29 | -------------------------------------------------------------------------------- /reflect/ValueOf.md: -------------------------------------------------------------------------------- 1 | # func ValueOf(i interface{}) Value 2 | 3 | 参数列表 4 | 5 | - i interface{} 传入任何变量类型 6 | 7 | 返回值: 8 | 9 | - Value 返回一个特定的 reflect.Value 类型 10 | 11 | 功能说明: 12 | 13 | - reflect.ValueOf(interface{}) 反射返回一个存储在接口 i 的值。 14 | 15 | 代码实例: 16 | 17 | package main 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | func main(){ 24 | var a int 25 | var value reflect.Value = reflect.ValueOf(a) 26 | fmt.Println(value) 27 | //>> 28 | } 29 | -------------------------------------------------------------------------------- /regexp/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /regexp/syntax/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /runtime/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /runtime/cgo/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /runtime/debug/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /runtime/pprof/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /sort/Float64s.md: -------------------------------------------------------------------------------- 1 | ## func Float64s(a []float64) 2 | 3 | 参数列表 4 | 5 | - a 表示要排序的 float64 切片 6 | 7 | 功能说明: 8 | 9 | Float64s 以升序排列 float64 切片 10 | 11 | 代码实例: 12 | 13 | package main 14 | 15 | import ( 16 | "fmt" 17 | "sort" 18 | ) 19 | 20 | func main() { 21 | a := []float64{5.5, 2.2, 6.6, 3.3, 1.1, 4.4} // unsorted 22 | sort.Float64s(a) 23 | fmt.Println(a) 24 | // Output: [1.1 2.2 3.3 4.4 5.5 6.6] 25 | } 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /sort/Ints.md: -------------------------------------------------------------------------------- 1 | ## func Ints(a []int) 2 | 3 | 参数列表 4 | 5 | - a 表示要排序的 int 切片 6 | 7 | 功能说明: 8 | 9 | Ints 以升序排列 int 切片 10 | 11 | 代码实例: 12 | 13 | package main 14 | 15 | import ( 16 | "fmt" 17 | "sort" 18 | ) 19 | 20 | func main() { 21 | a := []int{5, 2, 6, 3, 1, 4} // unsorted 22 | sort.Ints(a) 23 | fmt.Println(a) // [1 2 3 4 5 6] 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /sort/Reverse.md: -------------------------------------------------------------------------------- 1 | ## func Reverse(data Interface) Interface 2 | 3 | 参数列表 4 | 5 | - data 表示要逆序的 Interface 数据 6 | 7 | 返回值: 8 | 9 | - 返回 Interface 10 | 11 | 功能说明: 12 | 13 | - Reverse 返回逆序的Inferface数据 14 | 15 | 代码案例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "sort" 22 | ) 23 | 24 | func main() { 25 | s := []int{5, 2, 6, 3, 1, 4} // unsorted 26 | sort.Sort(sort.Reverse(sort.IntSlice(s))) 27 | fmt.Println(s) // [6 5 4 3 2 1] 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /sort/Strings.md: -------------------------------------------------------------------------------- 1 | ## func Strings(a []string) 2 | 3 | 参数列表 4 | 5 | - a 表示要排序的 string 切片 6 | 7 | 功能说明: 8 | 9 | Strings 以升序排列 string 切片 10 | 11 | 代码实例: 12 | 13 | package main 14 | 15 | import ( 16 | "fmt" 17 | "sort" 18 | ) 19 | 20 | func main() { 21 | a := []string{"PHP", "golang", "java", "python", "C", "Objective-C"} 22 | sort.Strings(a) 23 | fmt.Println(a) // [C Objective-C PHP golang java python] 24 | } 25 | 26 | -------------------------------------------------------------------------------- /sort/StringsAreSorted.md: -------------------------------------------------------------------------------- 1 | ## func StringsAreSorted(a []string) bool 2 | 3 | 参数列表 4 | 5 | - a 表示要判断的 string 切片 6 | 7 | 功能说明: 8 | 9 | StringsAreSorted 判断 string 切片是否已经按升序排列 10 | 11 | 代码案例: 12 | 13 | package main 14 | 15 | import ( 16 | "fmt" 17 | "sort" 18 | ) 19 | 20 | func main() { 21 | a := []string{"PHP", "golang", "java", "python", "C", "Objective-C"} 22 | fmt.Println(sort.StringsAreSorted(a)) // false 23 | sort.Strings(a) 24 | fmt.Println(sort.StringsAreSorted(a)) //true 25 | } 26 | -------------------------------------------------------------------------------- /strconv/Atoi.md: -------------------------------------------------------------------------------- 1 | # func Atoi(s string) (i int, err error) 2 | 3 | 参数列表 4 | 5 | - s 表示数字字符串,如“1234” 6 | 7 | 返回值: 8 | 9 | - i 表示转换后的数值 10 | 11 | 功能说明: 12 | 13 | - Atoi是函数ParseInt(s, 10, 0)的简写。把字符串格式的数字如“12345”转化为数字12345 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "strconv" 22 | ) 23 | 24 | func main() { 25 | fmt.Println(strconv.Atoi("12345")) 26 | fmt.Println(strconv.Atoi("abcde")) 27 | } 28 | 29 | 30 | 代码输出: 31 | 32 | 12345 33 | 0 strconv.ParseInt: parsing "abcde": invalid syntax -------------------------------------------------------------------------------- /strconv/FormatBool.md: -------------------------------------------------------------------------------- 1 | # func FormatBool(b bool) string 2 | 3 | 参数列表 4 | 5 | - b 需要被转换的bool值 6 | 7 | 返回值: 8 | 9 | - 返回string 表示转换后的字符串 10 | 11 | 功能说明: 12 | 13 | - 将true或false转换为字符串 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "strconv" 22 | ) 23 | 24 | func main() { 25 | b := strconv.FormatBool(true) 26 | fmt.Println(b) 27 | b = strconv.FormatBool(false) 28 | fmt.Println(b) 29 | } 30 | 31 | 32 | 代码输出: 33 | 34 | true 35 | false -------------------------------------------------------------------------------- /strconv/Itoa.md: -------------------------------------------------------------------------------- 1 | # func Itoa(i int) string 2 | 3 | 参数列表 4 | 5 | - i 表示需要被转换为字符串的int值 6 | 7 | 返回值: 8 | 9 | - 返回string 表示转换后的字符串。 10 | 11 | 功能说明: 12 | 13 | - 将数值按照10进制转换为字符串,是等同于FormatInt(i, 10)的简写。 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "strconv" 22 | ) 23 | 24 | func main() { 25 | fmt.Println(strconv.FormatInt(9223372036854775807, 10)) 26 | } 27 | 28 | 代码输出: 29 | 30 | 9223372036854775807 -------------------------------------------------------------------------------- /strconv/NumError.Error.md: -------------------------------------------------------------------------------- 1 | # func (e *NumError) Error() string 2 | 3 | 返回值: 4 | 5 | - 返回string 描述错误的字符串 6 | 7 | 功能说明: 8 | 9 | - 返回描述NumError类型错误的字符串 10 | 11 | 代码实例: 12 | 13 | package main 14 | 15 | import ( 16 | "fmt" 17 | "strconv" 18 | ) 19 | 20 | func main() { 21 | err := errors.New("too large") 22 | er := strconv.NumError{Func: "anyfunc", Num: "1e100",Err:err} 23 | fmt.Println(er.Error()) 24 | } 25 | 26 | 代码输出: 27 | 28 | strconv.anyfunc: parsing "1e100": too large -------------------------------------------------------------------------------- /strconv/Quote.md: -------------------------------------------------------------------------------- 1 | # func Quote(s string) string 2 | 3 | 参数列表 4 | 5 | - s 被引用的字符串 6 | 7 | 返回值: 8 | 9 | - 返回string 将s转换为被引用的字符串格式 10 | 11 | 功能说明: 12 | 13 | - 对s两侧添加双引号,并对s中的控制字符和不可打印的字符进行转义。 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "strconv" 22 | ) 23 | 24 | func main() { 25 | fmt.Println(strconv.Quote("abc 中文")) 26 | fmt.Println(strconv.Quote(strconv.Quote("abc 中文"))) 27 | } 28 | 29 | 代码输出: 30 | 31 | "abc\t中文" 32 | "\"abc\\t中文\"" -------------------------------------------------------------------------------- /strconv/QuoteRune.md: -------------------------------------------------------------------------------- 1 | # func QuoteRune(r rune) string 2 | 3 | 参数列表 4 | 5 | - r 被引用的rune字符 6 | 7 | 返回值: 8 | 9 | - 返回string 将r转换为被引用的字符格式 10 | 11 | 功能说明: 12 | 13 | - 对s两侧添加单引号,并对r中的控制字符和不可打印的字符进行转义。 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "strconv" 22 | ) 23 | 24 | func main() { 25 | fmt.Println(strconv.QuoteRune(' ')) 26 | fmt.Println(strconv.QuoteRune(100)) 27 | } 28 | 29 | 代码输出: 30 | 31 | '\t' 32 | 'd' -------------------------------------------------------------------------------- /strings/Count.md: -------------------------------------------------------------------------------- 1 | # func Count(s, sep string) int 2 | 3 | 参数列表 4 | 5 | - s 表示需要判断的主串 6 | - sep 需要计算的子串 7 | 8 | 返回值: 9 | 10 | - 返回int 表示s中包含sep的个数 11 | 12 | 功能说明: 13 | 14 | 这个函数主要是用来判断s中包含了多少个sep 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "strings" 23 | ) 24 | 25 | func main() { 26 | fmt.Println(strings.Count("cheese", "e")) //3 27 | fmt.Println(strings.Count("cheese", "ee")) //1 28 | fmt.Println(strings.Count("five", "")) // 5 29 | 30 | } -------------------------------------------------------------------------------- /strings/EqualFold.md: -------------------------------------------------------------------------------- 1 | # func EqualFold(s, t string) bool 2 | 3 | 参数列表 4 | 5 | - s 表示需要判断的主串 6 | - t 表示需要比较的辅串 7 | 8 | 返回值: 9 | 10 | - 返回bool 11 | 12 | 功能说明: 13 | 14 | 字符串s和t比较,它们在全部小写的情况下,采用UTF8编码的底层的unicode是否一致 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "strings" 23 | ) 24 | 25 | func main() { 26 | fmt.Println(strings.EqualFold("Go", "go")) //true 27 | } 28 | -------------------------------------------------------------------------------- /strings/Fields.md: -------------------------------------------------------------------------------- 1 | # func Fields(s string) []string 2 | 3 | 参数列表 4 | 5 | - s 表示需要判断的主串 6 | 7 | 返回值: 8 | 9 | - 返回[]string 10 | 11 | 功能说明: 12 | 13 | s按照一个空格或者多个连续的空格分割,返回分割之后的串数组,如果字符串没有空格或者只有一个空格,那么返回元素为去空格的s字符串 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "strings" 22 | ) 23 | 24 | func main() { 25 | fmt.Printf("Fields are: %q", strings.Fields(" foo bar baz ")) //Fields are: ["foo" "bar" "baz"] 26 | fmt.Printf("Fields are: %q", strings.Fields(" baz ")) //Fields are: ["bar"] 27 | } 28 | -------------------------------------------------------------------------------- /strings/HasPrefix.md: -------------------------------------------------------------------------------- 1 | # func HasPrefix(s, prefix string) bool 2 | 3 | 参数列表 4 | 5 | - s 表示需要判断的主串 6 | - prefix 需要判断的前缀字符串 7 | 8 | 返回值: 9 | 10 | - 返回bool, 11 | 12 | 功能说明: 13 | 14 | 该函数主要判断s串中是否含有前缀prefix,如果包含,那么返回true,否则返回false 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "strings" 23 | ) 24 | 25 | func main() { 26 | fmt.Println(strings.HasPrefix("astaxie", "as")) //true 27 | fmt.Println(strings.HasPrefix("astaxie", "ta")) //false 28 | } -------------------------------------------------------------------------------- /strings/HasSuffix.md: -------------------------------------------------------------------------------- 1 | # func HasSuffix(s, suffix string) bool 2 | 3 | 参数列表 4 | 5 | - s 表示需要判断的主串 6 | - suffix 需要判断的后缀字符串 7 | 8 | 返回值: 9 | 10 | - 返回bool, 11 | 12 | 功能说明: 13 | 14 | 该函数主要判断s串中是否含有后缀suffix,如果包含,那么返回true,否则返回false 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "strings" 23 | ) 24 | 25 | func main() { 26 | fmt.Println(strings.HasSuffix("astaxie", "as")) //false 27 | fmt.Println(strings.HasSuffix("astaxie", "xie")) //true 28 | } -------------------------------------------------------------------------------- /strings/Index.md: -------------------------------------------------------------------------------- 1 | # func Index(s, sep string) int 2 | 3 | 参数列表 4 | 5 | - s 表示需要判断的主串 6 | - sep 需要判断的第一次出现位置的字符串 7 | 8 | 返回值: 9 | 10 | - 返回int,对应sep出现在s中的位置 11 | 12 | 功能说明: 13 | 14 | 该函数主要判断sep串在s串中第一次出现的位置,如果不存在返回-1 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "strings" 23 | ) 24 | 25 | func main() { 26 | fmt.Println(strings.Index("chickenkenken", "ken")) //4 27 | fmt.Println(strings.Index("chicken", "dmr")) //-1 28 | } -------------------------------------------------------------------------------- /strings/IndexAny.md: -------------------------------------------------------------------------------- 1 | # func IndexAny(s, chars string) int 2 | 3 | 参数列表 4 | 5 | - s 表示需要判断的主串 6 | - chars 需要判断的第一次出现位置的字符集 7 | 8 | 返回值: 9 | 10 | - 返回int,对应sep出现在s中的位置 11 | 12 | 功能说明: 13 | 14 | 该函数主要判断chars集中任意的一个字符在s串中第一次出现的位置,如果不存在返回-1 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "strings" 23 | ) 24 | 25 | func main() { 26 | fmt.Println(strings.IndexAny("chickenkenkenken", "iken")) //2 27 | fmt.Println(strings.IndexAny("chicken", "dmr")) //-1 28 | } -------------------------------------------------------------------------------- /strings/IndexRune.md: -------------------------------------------------------------------------------- 1 | # func IndexRune(s string, r rune) int 2 | 3 | 参数列表 4 | 5 | - s 表示需要判断的主串 6 | - r 需要判断的第一次出现位置的unicode码 7 | 返回值: 8 | 9 | - 返回int,对应r出现在s中的位置 10 | 11 | 功能说明: 12 | 13 | 该函数主要判断unicode r在s串中第一次出现的位置,如果不存在返回-1 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "strings" 22 | ) 23 | 24 | func main() { 25 | fmt.Println(strings.IndexRune("chicken", 'k')) //4 26 | fmt.Println(strings.IndexRune("chicken", 'd')) //-1 27 | } 28 | -------------------------------------------------------------------------------- /strings/Join.md: -------------------------------------------------------------------------------- 1 | # func Join(a []string, sep string) string 2 | 3 | 参数列表 4 | 5 | - a 表示需要链接起来的字符串slice 6 | - sep 表示链接的符号 7 | 8 | 返回值: 9 | 10 | - 返回string 11 | 12 | 功能说明: 13 | 14 | 该函数主要实现字符串slice的链接功能,把slice的每一个元素通过sep进行链接 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "strings" 23 | ) 24 | 25 | func main() { 26 | s := []string{"foo", "bar", "baz"} 27 | fmt.Println(strings.Join(s, ", ")) //foo, bar, baz 28 | } -------------------------------------------------------------------------------- /strings/LastIndex.md: -------------------------------------------------------------------------------- 1 | # func LastIndex(s, sep string) int 2 | 3 | 参数列表 4 | 5 | - s 表示需要判断的对象字符串 6 | - sep 表示最后出现的字符串 7 | 8 | 返回值: 9 | 10 | - 返回int 11 | 12 | 功能说明: 13 | 14 | 该函数主要判断sep串在s串中最后一次出现的位置,如果不存在返回-1 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "strings" 23 | ) 24 | 25 | func main() { 26 | fmt.Println(strings.LastIndex("chickenkenken", "ken")) //10 27 | fmt.Println(strings.LastIndex("chicken", "dmr")) //-1 28 | } -------------------------------------------------------------------------------- /strings/LastIndexAny.md: -------------------------------------------------------------------------------- 1 | # func LastIndexAny(s, chars string) int 2 | 3 | 参数列表 4 | 5 | - s 表示需要判断的主串 6 | - chars 需要判断的最后一次出现位置的字符集 7 | 8 | 返回值: 9 | 10 | - 返回int,对应sep出现在s中的最后位置 11 | 12 | 功能说明: 13 | 14 | 该函数主要判断chars集中任意的一个字符在s串中最后一次出现的位置,如果不存在返回-1 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "strings" 23 | ) 24 | 25 | func main() { 26 | fmt.Println(strings.LastIndexAny("chickenkenkenken", "iken")) //15 27 | fmt.Println(strings.LastIndexAny("chicken", "dmr")) //-1 28 | } -------------------------------------------------------------------------------- /strings/Repeat.md: -------------------------------------------------------------------------------- 1 | # func Repeat(s string, count int) string 2 | 3 | 参数列表 4 | 5 | - s 表示需要重复的字符串 6 | - count 表示重复字数 7 | 8 | 返回值: 9 | 10 | - 返回string 重复的字符串 11 | 12 | 功能说明: 13 | 14 | 该函数返回一个s的重复count字数的字符串 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "strings" 23 | ) 24 | 25 | func main() { 26 | fmt.Println("ba" + strings.Repeat("na", 2)) //banana 27 | } 28 | -------------------------------------------------------------------------------- /strings/SplitAfter.md: -------------------------------------------------------------------------------- 1 | # func SplitAfter(s, sep string) []string 2 | 3 | 参数列表 4 | 5 | - s 表示需要处理的字符串 6 | - sep 表示分割的字符串 7 | 8 | 返回值: 9 | 10 | - 返回[]string 分割之后的字符串slice 11 | 12 | 功能说明: 13 | 14 | 该函数s根据sep分割,返回分割之后子字符串的slice,和split一样,只是返回的子字符串保留sep,如果sep为空,那么每一个字符都分割 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "strings" 23 | ) 24 | 25 | func main() { 26 | fmt.Printf("%q\n", strings.SplitAfter("a,b,c", ",")) //["a," "b," "c"] 27 | } 28 | 29 | -------------------------------------------------------------------------------- /strings/Title.md: -------------------------------------------------------------------------------- 1 | # func Title(s string) string 2 | 3 | 参数列表 4 | 5 | - s 表示需要处理的字符串 6 | 7 | 返回值: 8 | 9 | - 返回string 转化之后的字符串 10 | 11 | 功能说明: 12 | 13 | 该函数把s字符串里面的每个单词首字母转化为大写 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "strings" 22 | ) 23 | 24 | func main() { 25 | fmt.Println(strings.Title("her royal highness")) 26 | //Her Royal Highness 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /strings/ToLower.md: -------------------------------------------------------------------------------- 1 | # func ToLower(s string) string 2 | 3 | 参数列表 4 | 5 | - s 表示需要处理的字符串 6 | 7 | 返回值: 8 | 9 | - 返回string 转化之后的字符串 10 | 11 | 功能说明: 12 | 13 | 该函数把s字符串里面的每个单词转化为小写 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "strings" 22 | ) 23 | 24 | func main() { 25 | fmt.Println(strings.ToLower("Gopher")) 26 | //gopher 27 | } -------------------------------------------------------------------------------- /strings/ToLowerSpecial.md: -------------------------------------------------------------------------------- 1 | # func ToLowerSpecial(_case unicode.SpecialCase, s string) string 2 | 3 | 参数列表 4 | 5 | - _case 表示unicode的SpecialCase对象 6 | - s 表示需要处理的字符串 7 | 8 | 返回值: 9 | 10 | - 返回string 转化之后的字符串 11 | 12 | 功能说明: 13 | 14 | 该函数把s字符串里面的每个单词转化为小写,但是调用的是unicode.SpecialCase的ToLower方法 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "strings" 23 | "unicode" 24 | ) 25 | 26 | func main() { 27 | var SC unicode.SpecialCase 28 | fmt.Println(strings.ToLowerSpecial(SC, "Gopher")) 29 | //gopher 30 | } 31 | -------------------------------------------------------------------------------- /strings/ToTitle.md: -------------------------------------------------------------------------------- 1 | # func ToTitle(s string) string 2 | 3 | 参数列表 4 | 5 | - s 表示需要处理的字符串 6 | 7 | 返回值: 8 | 9 | - 返回string 转化之后的字符串 10 | 11 | 功能说明: 12 | 13 | 该函数把s字符串里面的每个字符转化为对应的大写字符,其实和ToUpper一样的效果,但是有些语种的unicode,ToTitle和ToUpper效果不一样,但是我没试出来过,英语至少是一样的。 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "strings" 22 | ) 23 | 24 | func main() { 25 | fmt.Println(strings.ToTitle("Gopher")) 26 | //GOPHER 27 | } 28 | -------------------------------------------------------------------------------- /strings/ToTitleSpecial.md: -------------------------------------------------------------------------------- 1 | # func ToTitleSpecial(_case unicode.SpecialCase, s string) string 2 | 3 | 参数列表 4 | 5 | - _case 表示unicode的SpecialCase对象 6 | - s 表示需要处理的字符串 7 | 8 | 返回值: 9 | 10 | - 返回string 转化之后的字符串 11 | 12 | 功能说明: 13 | 14 | 该函数把s字符串里面的每个单词转化为标题体,但是调用的是unicode.SpecialCase的ToTitle方法 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "strings" 23 | "unicode" 24 | ) 25 | 26 | func main() { 27 | var SC unicode.SpecialCase 28 | fmt.Println(strings.ToTitleSpecial(SC, "Gopher")) 29 | //GOPHER 30 | } 31 | -------------------------------------------------------------------------------- /strings/ToUpper.md: -------------------------------------------------------------------------------- 1 | # func ToUpper(s string) string 2 | 3 | 参数列表 4 | 5 | - s 表示需要处理的字符串 6 | 7 | 返回值: 8 | 9 | - 返回string 转化之后的字符串 10 | 11 | 功能说明: 12 | 13 | 该函数把s字符串里面的每个字符转化为大写 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "strings" 22 | ) 23 | 24 | func main() { 25 | fmt.Println(strings.ToUpper("Gopher")) 26 | //GOPHER 27 | } -------------------------------------------------------------------------------- /strings/ToUpperSpecial.md: -------------------------------------------------------------------------------- 1 | # func ToUpperSpecial(_case unicode.SpecialCase, s string) string 2 | 3 | 参数列表 4 | 5 | - _case 表示unicode的SpecialCase对象 6 | - s 表示需要处理的字符串 7 | 8 | 返回值: 9 | 10 | - 返回string 转化之后的字符串 11 | 12 | 功能说明: 13 | 14 | 该函数把s字符串里面的每个单词转化为大写,但是调用的是unicode.SpecialCase的ToUpper方法 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "strings" 23 | "unicode" 24 | ) 25 | 26 | func main() { 27 | var SC unicode.SpecialCase 28 | fmt.Println(strings.ToUpperSpecial(SC, "Gopher")) 29 | //GOPHER 30 | } 31 | -------------------------------------------------------------------------------- /strings/Trim.md: -------------------------------------------------------------------------------- 1 | # func Trim(s string, cutset string) string 2 | 3 | 参数列表 4 | 5 | - s 表示需要处理的字符串 6 | - cutset 表示需要过滤的字符集 7 | 8 | 返回值: 9 | 10 | - 返回string 转化之后的字符串 11 | 12 | 功能说明: 13 | 14 | 该函数把s字符串开头或者结尾里面包含字符集的字符全部过滤掉,返回过滤之后的字符串 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "strings" 23 | ) 24 | 25 | func main() { 26 | fmt.Printf("[%q]", strings.Trim(" !!! Achtung !!! ", "! ")) 27 | //["Achtung"] 28 | } -------------------------------------------------------------------------------- /strings/TrimLeft.md: -------------------------------------------------------------------------------- 1 | # func TrimLeft(s string, cutset string) string 2 | 3 | 参数列表 4 | 5 | - s 表示需要处理的字符串 6 | - cutset 表示需要过滤的字符集 7 | 8 | 返回值: 9 | 10 | - 返回string 转化之后的字符串 11 | 12 | 功能说明: 13 | 14 | 该函数把s字符串开头里面包含字符集的字符全部过滤掉,返回过滤之后的字符串 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "strings" 23 | ) 24 | 25 | func main() { 26 | fmt.Printf("[%q]", strings.TrimLeft(" !!! Achtung !!! ", "! ")) 27 | //["Achtung !!! "] 28 | } -------------------------------------------------------------------------------- /strings/TrimRight.md: -------------------------------------------------------------------------------- 1 | # func TrimRight(s string, cutset string) string 2 | 3 | 参数列表 4 | 5 | - s 表示需要处理的字符串 6 | - cutset 表示需要过滤的字符集 7 | 8 | 返回值: 9 | 10 | - 返回string 转化之后的字符串 11 | 12 | 功能说明: 13 | 14 | 该函数把s字符串结尾里面包含字符集的字符全部过滤掉,返回过滤之后的字符串 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "strings" 23 | ) 24 | 25 | func main() { 26 | fmt.Printf("[%q]", strings.TrimRight(" !!! Achtung !!! ", "! ")) 27 | //[" !!! Achtung"] 28 | } -------------------------------------------------------------------------------- /strings/TrimSpace.md: -------------------------------------------------------------------------------- 1 | # func TrimSpace(s string) string 2 | 3 | 参数列表 4 | 5 | - s 表示需要处理的字符串 6 | 7 | 返回值: 8 | 9 | - 返回string 转化之后的字符串 10 | 11 | 功能说明: 12 | 13 | 该函数把s字符串开头或者结尾里面空白符('\t', '\n', '\v', '\f', '\r', ' ', U+0085 (NEL), U+00A0 (NBSP))全部过滤掉,返回过滤之后的字符串 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "strings" 22 | ) 23 | 24 | func main() { 25 | fmt.Println(strings.TrimSpace(" \t\n a lone gopher \n\t\r\n")) 26 | //a lone gopher 27 | } -------------------------------------------------------------------------------- /sync/type_locker.md: -------------------------------------------------------------------------------- 1 | #type Locker 2 | 3 | Locker是一个接口类型。 4 | 5 | type Locker interface { 6 | Lock() 7 | Unlock() 8 | } 9 | 10 | 你可以在mutux.go中找到它的定义。 11 | 12 | 它提供了一个抽象接口,被Mutex和RWMutex实现,是Cond的成员。 -------------------------------------------------------------------------------- /syscall/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /testing/B.md: -------------------------------------------------------------------------------- 1 | ## type B 2 | 3 | 结构: 4 | 5 | type B struct { 6 | N int 7 | // 包括被过滤或未被导出的字段 8 | } 9 | 10 | 类型说明: 11 | 12 | B是一个类型,它会被传递给Benchmark函数,用于管理基准测试定时和指定迭代运行次数(N)。 13 | 14 | 代码实例: 15 | 16 | package testing_demo 17 | 18 | import ( 19 | "testing" 20 | ) 21 | 22 | func Benchmark(b *testing.B) { 23 | b.Logf("N: %d\n", b.N) 24 | } 25 | 26 | 运行方法: 27 | 28 | 将上面的实例代码保存在文件“$GOPATH/src/testing_demo/b_test.go”中。用命令行进入文件所在目录并运行命令“go test -bench="." -v”,观察输出,相信你会懂的。 29 | -------------------------------------------------------------------------------- /testing/B_Error.md: -------------------------------------------------------------------------------- 1 | ## func (c *B) Error(args ...interface{}) 2 | 3 | 参数列表 4 | 5 | - args 要输出的、用于描述错误的内容 6 | 7 | 返回值: 8 | 9 | <无> 10 | 11 | 功能说明: 12 | 13 | 调用Error()相当于在调用了Log()之后再调用Fail()。 14 | 15 | 代码实例: 16 | 17 | package testing_demo 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | func Benchmark(b *testing.B) { 24 | b.Error("Error:", "E") 25 | } 26 | 27 | 运行方法: 28 | 29 | 将上面的实例代码保存在文件“$GOPATH/src/testing_demo/b_error_test.go”中。用命令行进入文件所在目录并运行命令“go test -bench="." -v”。 30 | -------------------------------------------------------------------------------- /testing/B_Fail.md: -------------------------------------------------------------------------------- 1 | ## func (c *B) Fail() 2 | 3 | 参数列表 4 | 5 | <无> 6 | 7 | 返回值: 8 | 9 | <无> 10 | 11 | 功能说明: 12 | 13 | 调用Fail()使得当前测试函数失败,但扔会继续执行后面的代码。 14 | 15 | 代码实例: 16 | 17 | package testing_demo 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | func Benchmark(b *testing.B) { 24 | b.Fail() 25 | } 26 | 27 | 运行方法: 28 | 29 | 将上面的实例代码保存在文件“$GOPATH/src/testing_demo/b_fail_test.go”中。用命令行进入文件所在目录并运行命令“go test -bench="." -v”。 30 | -------------------------------------------------------------------------------- /testing/B_FailNow.md: -------------------------------------------------------------------------------- 1 | ## func (c *B) FailNow() 2 | 3 | 参数列表 4 | 5 | <无> 6 | 7 | 返回值: 8 | 9 | <无> 10 | 11 | 功能说明: 12 | 13 | 调用Fail()使得当前测试函数失败且停止执行,转而执行后面的测试函数或基准测试函数。 14 | 15 | 代码实例: 16 | 17 | package testing_demo 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | func Benchmark(b *testing.B) { 24 | b.FailNow() 25 | } 26 | 27 | 运行方法: 28 | 29 | 将上面的实例代码保存在文件“$GOPATH/src/testing_demo/b_failnow_test.go”中。用命令行进入文件所在目录并运行命令“go test -bench="." -v”。 30 | -------------------------------------------------------------------------------- /testing/B_Failed.md: -------------------------------------------------------------------------------- 1 | ## func (c *B) Failed() bool 2 | 3 | 参数列表 4 | 5 | <无> 6 | 7 | 返回值: 8 | 9 | - bool值,测试函数是否已失败。 10 | 11 | 功能说明: 12 | 13 | 判断测试函数是否已失败。 14 | 15 | 代码实例: 16 | 17 | package testing_demo 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | func Benchmark(b *testing.B) { 24 | b.Logf("Failed: %v\n", b.Failed()) 25 | } 26 | 27 | 运行方法: 28 | 29 | 将上面的实例代码保存在文件“$GOPATH/src/testing_demo/b_failed_test.go”中。用命令行进入文件所在目录并运行命令“go test -bench="." -v”。 30 | -------------------------------------------------------------------------------- /testing/B_Fatal.md: -------------------------------------------------------------------------------- 1 | ## func (c *B) Fatal(args ...interface{}) 2 | 3 | 参数列表 4 | 5 | - args 要输出的、用于描述错误的内容 6 | 7 | 返回值: 8 | 9 | <无> 10 | 11 | 功能说明: 12 | 13 | 调用Error()相当于在调用了Log()之后再调用FailNow()。 14 | 15 | 代码实例: 16 | 17 | package testing_demo 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | func Benchmark(b *testing.B) { 24 | b.Fatal("Fatal:", "F") 25 | } 26 | 27 | 运行方法: 28 | 29 | 将上面的实例代码保存在文件“$GOPATH/src/testing_demo/b_fatal_test.go”中。用命令行进入文件所在目录并运行命令“go test -bench="." -v”。 30 | -------------------------------------------------------------------------------- /testing/B_Log.md: -------------------------------------------------------------------------------- 1 | ## func (c *B) Log(args ...interface{}) 2 | 3 | 参数列表 4 | 5 | - args 要输出的、用于描述错误的内容 6 | 7 | 返回值: 8 | 9 | <无> 10 | 11 | 功能说明: 12 | 13 | Log方法用默认的格式来格式化给定的参数,类似于Println(),并在错误日志中记录文本。 14 | 15 | 代码实例: 16 | 17 | package testing_demo 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | func Benchmark(b *testing.B) { 24 | b.Log("Log:", "L") 25 | } 26 | 27 | 运行方法: 28 | 29 | 将上面的实例代码保存在文件“$GOPATH/src/testing_demo/b_log_test.go”中。用命令行进入文件所在目录并运行命令“go test -bench="." -v”。 30 | -------------------------------------------------------------------------------- /testing/Benchmark.md: -------------------------------------------------------------------------------- 1 | ## func Benchmark(f func(b *B)) BenchmarkResult 2 | 3 | 参数列表 4 | 5 | - f 要被测试的函数 6 | 7 | 返回值: 8 | 9 | - BenchmarkResult实例值,基准测试结果。 10 | 11 | 功能说明: 12 | 13 | Benchmark()用来测试单一函数。它可以被用于在不使用“go test”命令的情况下创建自定义的基准测试。 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "testing" 22 | ) 23 | 24 | func main() { 25 | br := testing.Benchmark(func(b *testing.B) { b.Log("B!") }) 26 | fmt.Printf("Benchmark Result: %v\n", br) 27 | } 28 | -------------------------------------------------------------------------------- /testing/InternalBenchmark.md: -------------------------------------------------------------------------------- 1 | ## type InternalBenchmark 2 | 3 | 结构: 4 | 5 | type InternalBenchmark struct { 6 | Name string 7 | F func(b *B) 8 | } 9 | 10 | 类型说明: 11 | 12 | 一个内部类型,只为了跨包使用而成为可导出的;它是“go test”命令实现的一部分。 13 | 14 | 代码实例: 15 | 16 | package main 17 | 18 | import ( 19 | "fmt" 20 | "testing" 21 | ) 22 | 23 | func main() { 24 | iBenchmark := testing.InternalBenchmark{Name: "DemoBenchMark", F: func(b *testing.B) {}} 25 | fmt.Printf("Benchmark: %v\n", iBenchmark) 26 | } 27 | -------------------------------------------------------------------------------- /testing/InternalExample.md: -------------------------------------------------------------------------------- 1 | ## type InternalBenchmark 2 | 3 | 结构: 4 | 5 | type InternalExample struct { 6 | Name string 7 | F func() 8 | Output string 9 | } 10 | 11 | 类型说明: 12 | 13 | 一个内部类型,只为了跨包使用而成为可导出的;它是“go test”命令实现的一部分。 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "testing" 22 | ) 23 | 24 | func main() { 25 | iExample := testing.InternalExample{Name: "Example", F: func() {}, Output: ""} 26 | fmt.Printf("Example: %v\n", iExample) 27 | } 28 | -------------------------------------------------------------------------------- /testing/InternalTest.md: -------------------------------------------------------------------------------- 1 | ## type InternalTest 2 | 3 | 结构: 4 | 5 | type InternalTest struct { 6 | Name string 7 | F func(*T) 8 | } 9 | 10 | 类型说明: 11 | 12 | 一个内部类型,只为了跨包使用而成为可导出的;它是“go test”命令实现的一部分。 13 | 14 | 代码实例: 15 | 16 | package main 17 | 18 | import ( 19 | "fmt" 20 | "testing" 21 | ) 22 | 23 | func main() { 24 | iTest := testing.InternalTest{Name: "DemoTest", F: func(t *testing.T) {}} 25 | fmt.Printf("Test: %v\n", iTest) 26 | } 27 | -------------------------------------------------------------------------------- /testing/T.md: -------------------------------------------------------------------------------- 1 | ## type T 2 | 3 | 结构: 4 | 5 | type T struct { 6 | // 包括被过滤或未被导出的字段 7 | } 8 | 9 | 类型说明: 10 | 11 | T是一个类型,它会被传递给Test函数,用于管理测试状态并支持格式化了的测试日志。日志会在测试执行及标准错误被抛出的时候累积,并在测试完成时一并输出。 12 | 13 | 代码实例: 14 | 15 | package testing_demo 16 | 17 | import ( 18 | "testing" 19 | ) 20 | 21 | func Test(t *testing.T) { 22 | t.Log("Testing...") 23 | } 24 | 25 | 运行方法: 26 | 27 | 将上面的实例代码保存在文件“$GOPATH/src/testing_demo/t_test.go”中。用命令行进入文件所在目录并运行命令“go test -v”。 28 | -------------------------------------------------------------------------------- /testing/T_Error.md: -------------------------------------------------------------------------------- 1 | ## func (c *T) Error(args ...interface{}) 2 | 3 | 参数列表 4 | 5 | - args 要输出的、用于描述错误的内容 6 | 7 | 返回值: 8 | 9 | <无> 10 | 11 | 功能说明: 12 | 13 | 调用Error()相当于在调用了Log()之后再调用Fail()。 14 | 15 | 代码实例: 16 | 17 | import ( 18 | "testing" 19 | ) 20 | 21 | func Test(t *testing.T) { 22 | t.Error("Error:", "E") 23 | } 24 | 25 | 运行方法: 26 | 27 | 将上面的实例代码保存在文件“$GOPATH/src/testing_demo/t_error_test.go”中。用命令行进入文件所在目录并运行命令“go test -v”。 28 | -------------------------------------------------------------------------------- /testing/T_Errorf.md: -------------------------------------------------------------------------------- 1 | ## func (c *T) Errorf(format string, args ...interface{}) 2 | 3 | 参数列表 4 | 5 | - format 格式字符串 6 | - args 要输出的、用于描述错误的内容 7 | 8 | 返回值: 9 | 10 | <无> 11 | 12 | 功能说明: 13 | 14 | 调用Error()相当于在调用了Logf()之后再调用Fail()。 15 | 16 | 代码实例: 17 | 18 | package testing_demo 19 | 20 | import ( 21 | "testing" 22 | ) 23 | 24 | func Test(t *testing.T) { 25 | t.Errorf("Error: %s\n", "EF") 26 | } 27 | 28 | 运行方法: 29 | 30 | 将上面的实例代码保存在文件“$GOPATH/src/testing_demo/t_errorf_test.go”中。用命令行进入文件所在目录并运行命令“go test -v”。 31 | -------------------------------------------------------------------------------- /testing/T_Fail.md: -------------------------------------------------------------------------------- 1 | ## func (c *T) Fail() 2 | 3 | 参数列表 4 | 5 | <无> 6 | 7 | 返回值: 8 | 9 | <无> 10 | 11 | 功能说明: 12 | 13 | 调用Fail()使得当前测试函数失败,但扔会继续执行后面的代码。 14 | 15 | 代码实例: 16 | 17 | package testing_demo 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | func Test(t *testing.T) { 24 | t.Fail() 25 | } 26 | 27 | 运行方法: 28 | 29 | 将上面的实例代码保存在文件“$GOPATH/src/testing_demo/t_fail_test.go”中。用命令行进入文件所在目录并运行命令“go test -v”。 30 | -------------------------------------------------------------------------------- /testing/T_FailNow.md: -------------------------------------------------------------------------------- 1 | ## func (c *T) FailNow() 2 | 3 | 参数列表 4 | 5 | <无> 6 | 7 | 返回值: 8 | 9 | <无> 10 | 11 | 功能说明: 12 | 13 | 调用Fail()使得当前测试函数失败且停止执行,转而执行后面的测试函数或基准测试函数。 14 | 15 | 代码实例: 16 | 17 | package testing_demo 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | func Test(t *testing.T) { 24 | t.FailNow() 25 | } 26 | 27 | 运行方法: 28 | 29 | 将上面的实例代码保存在文件“$GOPATH/src/testing_demo/t_failnow_test.go”中。用命令行进入文件所在目录并运行命令“go test -v”。 30 | -------------------------------------------------------------------------------- /testing/T_Failed.md: -------------------------------------------------------------------------------- 1 | ## func (c *B) Failed() bool 2 | 3 | 参数列表 4 | 5 | <无> 6 | 7 | 返回值: 8 | 9 | - bool值,测试函数是否已失败。 10 | 11 | 功能说明: 12 | 13 | 判断测试函数是否已失败。 14 | 15 | 代码实例: 16 | 17 | package testing_demo 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | func Test(t *testing.T) { 24 | t.Logf("Failed: %v\n", t.Failed()) 25 | } 26 | 27 | 运行方法: 28 | 29 | 将上面的实例代码保存在文件“$GOPATH/src/testing_demo/t_failed_test.go”中。用命令行进入文件所在目录并运行命令“go test -v”。 30 | -------------------------------------------------------------------------------- /testing/T_Fatal.md: -------------------------------------------------------------------------------- 1 | ## func (c *T) Fatal(args ...interface{}) 2 | 3 | 参数列表 4 | 5 | - args 要输出的、用于描述错误的内容 6 | 7 | 返回值: 8 | 9 | <无> 10 | 11 | 功能说明: 12 | 13 | 调用Error()相当于在调用了Log()之后再调用FailNow()。 14 | 15 | 代码实例: 16 | 17 | package testing_demo 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | func Test(t *testing.T) { 24 | t.Fatal("Fatal:", "F") 25 | } 26 | 27 | 运行方法: 28 | 29 | 将上面的实例代码保存在文件“$GOPATH/src/testing_demo/t_fatal_test.go”中。用命令行进入文件所在目录并运行命令“go test -v”。 30 | -------------------------------------------------------------------------------- /testing/T_Fatalf.md: -------------------------------------------------------------------------------- 1 | ## func (c *T) Fatalf(format string, args ...interface{}) 2 | 3 | 参数列表 4 | 5 | - format 格式字符串 6 | - args 要输出的、用于描述错误的内容 7 | 8 | 返回值: 9 | 10 | <无> 11 | 12 | 功能说明: 13 | 14 | 调用Error()相当于在调用了Logf()之后再调用FailNow()。 15 | 16 | 代码实例: 17 | 18 | package testing_demo 19 | 20 | import ( 21 | "testing" 22 | ) 23 | 24 | func Test(t *testing.T) { 25 | t.Fatalf("Fatal: %s\n", "FF") 26 | } 27 | 28 | 运行方法: 29 | 30 | 将上面的实例代码保存在文件“$GOPATH/src/testing_demo/t_fatalf_test.go”中。用命令行进入文件所在目录并运行命令“go test -v”。 31 | -------------------------------------------------------------------------------- /testing/T_Log.md: -------------------------------------------------------------------------------- 1 | ## func (c *T) Log(args ...interface{}) 2 | 3 | 参数列表 4 | 5 | - args 要输出的、用于描述错误的内容 6 | 7 | 返回值: 8 | 9 | <无> 10 | 11 | 功能说明: 12 | 13 | Log方法用默认的格式来格式化给定的参数,类似于Println(),并在错误日志中记录文本。 14 | 15 | 代码实例: 16 | 17 | package testing_demo 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | func Test(t *testing.T) { 24 | t.Log("Log:", "L") 25 | } 26 | 27 | 运行方法: 28 | 29 | 将上面的实例代码保存在文件“$GOPATH/src/testing_demo/t_log_test.go”中。用命令行进入文件所在目录并运行命令“go test -v”。 30 | -------------------------------------------------------------------------------- /testing/T_Logf.md: -------------------------------------------------------------------------------- 1 | ## func (c *T) Logf(format string, args ...interface{}) 2 | 3 | 参数列表 4 | 5 | - format 格式字符串 6 | - args 要输出的、用于描述错误的内容 7 | 8 | 返回值: 9 | 10 | <无> 11 | 12 | 功能说明: 13 | 14 | Logf方法根据给定的格式来格式化给定的参数,类似于Printf(),并在错误日志中记录文本。 15 | 16 | 代码实例: 17 | 18 | package testing_demo 19 | 20 | import ( 21 | "testing" 22 | ) 23 | 24 | func Test(t *testing.T) { 25 | t.Logf("Log: %s\n", "LF") 26 | } 27 | 28 | 运行方法: 29 | 30 | 将上面的实例代码保存在文件“$GOPATH/src/testing_demo/t_logf_test.go”中。用命令行进入文件所在目录并运行命令“go test -v”。 31 | -------------------------------------------------------------------------------- /testing/T_Parallel.md: -------------------------------------------------------------------------------- 1 | ## func (t *T) Parallel() 2 | 3 | 参数列表 4 | 5 | <无> 6 | 7 | 返回值: 8 | 9 | <无> 10 | 11 | 功能说明: 12 | 13 | 调用Parallel()方法使当前测试与(且仅与)其他可并列运行的(同样调用了Parallel()方法的)测试并列运行于当前 CPU 组中。 14 | 15 | 代码实例: 16 | 17 | package testing_demo 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | func Test(t *testing.T) { 24 | t.Parallel() 25 | } 26 | 27 | 运行方法: 28 | 29 | 将上面的实例代码保存在文件“$GOPATH/src/testing_demo/t_parallel_test.go”中。用命令行进入文件所在目录并运行命令“go test -v”。 30 | -------------------------------------------------------------------------------- /testing/iotest/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /testing/quick/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /text/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 包列表 4 | 5 | - [text/scanner](scanner) 6 | - xxx2 7 | -------------------------------------------------------------------------------- /text/scanner/IsValid.md: -------------------------------------------------------------------------------- 1 | ## func (pos *Position) IsValid() bool 2 | 3 | 参数列表: 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - 当期位置是否合法,bool类型 10 | 11 | 功能说明: 12 | 13 | 如果当期位置合法,返回true;如果当前位置不合法,返回false。 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import( 20 | "fmt" 21 | "strings" 22 | "text/scanner" 23 | ) 24 | 25 | func main(){ 26 | 27 | src := strings.NewReader("int num = 1;") 28 | var s scanner.Scanner 29 | 30 | s.Init(src) 31 | 32 | s.Next() 33 | 34 | pos := s.Pos() 35 | fmt.Println(pos.IsValid()) 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /text/scanner/Peek.md: -------------------------------------------------------------------------------- 1 | ## func (s *Scanner) Peek() rune 2 | 3 | 参数列表: 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - 返回下一个字符,rune类型 10 | 11 | 功能说明: 12 | 13 | 在不使词法解析器向前进一位的情况下,返回下一个字符。如果解析器当前位置已经在源的最后一位,返回EOF。 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import( 20 | "fmt" 21 | "strings" 22 | "text/scanner" 23 | ) 24 | 25 | func main(){ 26 | 27 | src := strings.NewReader("int num = 1;") 28 | 29 | var s scanner.Scanner 30 | s.Init(src) 31 | 32 | //this will print "i" to stdout 33 | fmt.Println(scanner.TokenString(s.Peek())) 34 | } 35 | 36 | -------------------------------------------------------------------------------- /text/scanner/Position.md: -------------------------------------------------------------------------------- 1 | type Position struct { 2 | Filename string // 文件名,可能为空 3 | Offset int // 位移,从0计 4 | Line int // 行数,从1计 5 | Column int // 列数,从1计(按字符计算) 6 | } 7 | 8 | Position用来表示源中的位置。行数Line > 0的情况下,Position合法。 9 | 10 | -------------------------------------------------------------------------------- /text/scanner/Scan.md: -------------------------------------------------------------------------------- 1 | ## func (s *Scanner) Scan() rune 2 | 3 | 参数列表: 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - 下一个字符或token 10 | 11 | 功能说明: 12 | 13 | Scan方法读取源中下一个token或字符,并返回。如果读到源的结尾,返回EOF。 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import( 20 | "fmt" 21 | "strings" 22 | "text/scanner" 23 | ) 24 | 25 | func main(){ 26 | 27 | src := strings.NewReader("int num = 1;") 28 | var s scanner.Scanner 29 | 30 | s.Init(src) 31 | 32 | s.Scan() 33 | //this will print the next token "int "to stdout 34 | fmt.Println(s.TokenText()) 35 | } 36 | 37 | -------------------------------------------------------------------------------- /text/scanner/TokenString.md: -------------------------------------------------------------------------------- 1 | ## func TokenString(tok rune) string 2 | 3 | 参数列表: 4 | 5 | - tok 待转换字符 6 | 7 | 返回值: 8 | 9 | - 返回可打印字符串 10 | 11 | 功能说明: 12 | 13 | 这个函数用来将tok转换为字符串 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import( 20 | "fmt" 21 | "text/scanner" 22 | ) 23 | func main(){ 24 | 25 | toks := []rune("abcdef") 26 | 27 | for _, tok := range toks{ 28 | fmt.Print(scanner.TokenString(tok)) 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /text/tabwriter/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /text/template/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /text/template/parse/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /time/Add.md: -------------------------------------------------------------------------------- 1 | # func (t Time) Add(d Duration) Time 2 | 3 | 参数列表: 4 | 5 | - d 时间间隔 6 | 7 | 返回值: 8 | 9 | - Time 10 | 11 | 功能说明: 12 | 13 | 返回时间(t + d) 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "time" 22 | ) 23 | 24 | func main() { 25 | now := time.Now() 26 | fmt.Println("now:", now) 27 | fmt.Println("after 3 hours", now.Add(3*time.Hour)) 28 | } 29 | -------------------------------------------------------------------------------- /time/AddDate.md: -------------------------------------------------------------------------------- 1 | # func (t Time) AddDate(years int, months int, days int) Time 2 | 3 | 参数列表: 4 | 5 | - years 年 6 | - months 月 7 | - days 日 8 | 9 | 返回值: 10 | 11 | - Time 12 | 13 | 功能说明: 14 | 15 | 生成由t加上参数中指定的年月日之后的时间,比如AddDate(-1, 2, 3) 使 January 1, 2011变为March 4, 2010。AddDate以和Date方法一样的方式标准化返回值,比如,10月31日加一个月之后为11月31日,标准化为12月1日 16 | 17 | 代码实例: 18 | 19 | package main 20 | 21 | import ( 22 | "fmt" 23 | "time" 24 | ) 25 | 26 | func main() { 27 | now := time.Now() 28 | fmt.Println(now.AddDate(2, 3, 4)) 29 | } -------------------------------------------------------------------------------- /time/AfterFunc.md: -------------------------------------------------------------------------------- 1 | # func AfterFunc(d Duration, f func()) *Timer 2 | 3 | 参数列表: 4 | 5 | - d 时间间隔 6 | - f 回调函数 7 | 8 | 返回值: 9 | 10 | - *Timer 11 | 12 | 功能说明: 13 | 14 | 经过时间d之后在自己的goroutine中调用f。可以调用返回的Timer的Stop方法来停止Timer。 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "time" 23 | ) 24 | 25 | func main() { 26 | f := func() { 27 | fmt.Println("Time out") 28 | } 29 | time.AfterFunc(2*time.Second, f) 30 | 31 | time.Sleep(3 * time.Second) 32 | } 33 | -------------------------------------------------------------------------------- /time/Duration.md: -------------------------------------------------------------------------------- 1 | # type Duration int64 2 | 3 | 以int64表示两个时间点之间的间隔(纳秒数),最多表示290年 4 | 5 | 常量 6 | 7 | - Nanosecond Duration = 1 8 | - Microsecond = 1000 * Nanosecond 9 | - Millissecond = 1000 * Microsecond 10 | - Second = 1000 * Millisecond 11 | - Minute = 60 * Second 12 | - Hour = 60 * Minute 13 | 14 | 通常没有天或者更大的时间单位,是为了避免混淆跨越夏令时区转换。 15 | -------------------------------------------------------------------------------- /time/Error.md: -------------------------------------------------------------------------------- 1 | # func (e *ParseError) Error() string 2 | 3 | 参数列表: 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - string 错误描述 -------------------------------------------------------------------------------- /time/FixedZone_Editing.md: -------------------------------------------------------------------------------- 1 | # func FixedZone(name string, offset int) *Location 2 | 3 | 参数列表: 4 | 5 | - name -------------------------------------------------------------------------------- /time/GobDecode.md: -------------------------------------------------------------------------------- 1 | # func (t *Time) GobDecode(buf []byte) error 2 | 3 | 参数列表: 4 | 5 | - buf gob数据 6 | 7 | 返回值: 8 | 9 | - error 错误 10 | 11 | 功能说明: 12 | 13 | GobDecode实现了gob.GobDecoder接口。 14 | 15 | 代码实例: 16 | 17 | 无 -------------------------------------------------------------------------------- /time/GobEncode.md: -------------------------------------------------------------------------------- 1 | # func (t Time) GobEncode() ([]byte, error) 2 | 3 | 参数列表: 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - []byte gob数据 10 | - error 错误 11 | 12 | 功能说明: 13 | 14 | GobEncode实现了gob.GobEncoder接口 15 | 16 | 代码实例: 17 | 18 | 无 -------------------------------------------------------------------------------- /time/Hours.md: -------------------------------------------------------------------------------- 1 | # func (d Duration) Hours() float64 2 | 3 | 参数列表: 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - float64 10 | 11 | 功能说明: 12 | 13 | 返回时间d以小时为单位的浮点数形式 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "time" 22 | ) 23 | 24 | func main() { 25 | d, _ := time.ParseDuration("3h4m2s") 26 | fmt.Println(d.Hours()) 27 | } 28 | -------------------------------------------------------------------------------- /time/ISOWeek.md: -------------------------------------------------------------------------------- 1 | # func (t Time) ISOWeek() (year, week int) 2 | 3 | 参数列表: 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - year 年 10 | - week 星期 11 | 12 | 功能说明: 13 | 14 | 返回时间t的在一年中的星期数。星期范围从1到53。每年的1月1日到3日可能会属于上一年的第52或者53周,每年的12月29日到31日可能属于下一年的第一周。 15 | 16 | 代码实例: 17 | 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | "time" 23 | ) 24 | 25 | func main() { 26 | t := time.Date(2013, time.January, 7, 15, 23, 4, 100, time.UTC) 27 | fmt.Println(t.ISOWeek()) 28 | } -------------------------------------------------------------------------------- /time/In.md: -------------------------------------------------------------------------------- 1 | # func (t Time) In(loc *Location) Time 2 | 3 | 参数列表: 4 | 5 | - loc 位置 6 | 7 | 返回值: 8 | 9 | - Time 10 | 11 | 功能说明: 12 | 13 | 返回location设为loc的t。如果loc为nil则函数panic 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "time" 22 | ) 23 | 24 | func main() { 25 | t := time.Now() 26 | fmt.Println(t) 27 | fmt.Println(t.In(time.UTC)) 28 | } 29 | -------------------------------------------------------------------------------- /time/Local.md: -------------------------------------------------------------------------------- 1 | # func (t Time) Local() Time 2 | 3 | 参数列表: 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - Time 10 | 11 | 功能说明: 12 | 13 | 返回本地时间。等价于t.In(time.Local) 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "time" 22 | ) 23 | 24 | func main() { 25 | t := time.Date(2013, time.March, 14, 15, 23, 4, 100, time.UTC) 26 | fmt.Println(t) 27 | fmt.Println(t.Local()) 28 | } 29 | -------------------------------------------------------------------------------- /time/MarshalJSON.md: -------------------------------------------------------------------------------- 1 | # func (t Time) MarshalJSON() ([]byte, error) 2 | 3 | 参数列表: 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - []byte json串 10 | - error 错误 11 | 12 | 功能说明: 13 | 14 | MarshalJSON实现了json.Marshaler接口。时间t按照RFC3339格式化。 15 | 16 | 代码实例: 17 | 18 | 无 -------------------------------------------------------------------------------- /time/Minutes.md: -------------------------------------------------------------------------------- 1 | # func (d Duration) Minutes() float64 2 | 3 | 参数列表: 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - float64 10 | 11 | 功能说明: 12 | 13 | 返回时间d以分钟为单位的浮点数形式 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "time" 22 | ) 23 | 24 | func main() { 25 | d, _ := time.ParseDuration("3h4m2s") 26 | fmt.Println(d.Minutes()) 27 | } 28 | -------------------------------------------------------------------------------- /time/Month.md: -------------------------------------------------------------------------------- 1 | # type Month int 2 | 3 | 一年中的一个月 4 | 5 | 常量: 6 | 7 | - January Month = 1 + iota 8 | - February 9 | - March 10 | - April 11 | - May 12 | - June 13 | - July 14 | - August 15 | - September 16 | - October 17 | - November 18 | - December 19 | 20 | 代码实例: 21 | 22 | package main 23 | 24 | import ( 25 | "fmt" 26 | "time" 27 | ) 28 | 29 | func main() { 30 | _, m, _ := time.Now().Date() 31 | fmt.Println(m) 32 | } -------------------------------------------------------------------------------- /time/Nanoseconds.md: -------------------------------------------------------------------------------- 1 | # func (d Duration) Nanoseconds() float64 2 | 3 | 参数列表: 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - float64 10 | 11 | 功能说明: 12 | 13 | 返回时间d以纳秒为单位的浮点数形式 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "time" 22 | ) 23 | 24 | func main() { 25 | d, _ := time.ParseDuration("2s3ms") 26 | fmt.Println(d.Nanoseconds()) 27 | } 28 | -------------------------------------------------------------------------------- /time/NewTimer.md: -------------------------------------------------------------------------------- 1 | # func NewTimer(d Duration) *Timer 2 | 3 | 参数列表: 4 | 5 | - d 时间间隔 6 | 7 | 返回值: 8 | 9 | - *Timer 10 | 11 | 功能说明: 12 | 13 | 新建一个Timer,在时间d之后将当前时间发送给C 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "time" 22 | ) 23 | 24 | func main() { 25 | timer := time.NewTimer(2 * time.Second) 26 | 27 | t := <-timer.C 28 | fmt.Println(t) 29 | } -------------------------------------------------------------------------------- /time/Now.md: -------------------------------------------------------------------------------- 1 | # func Now() Time 2 | 3 | 参数列表: 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - Time 10 | 11 | 功能说明: 12 | 13 | 返回当前的本地时间 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "time" 22 | ) 23 | 24 | func main() { 25 | fmt.Println(time.Now()) 26 | } 27 | -------------------------------------------------------------------------------- /time/ParseDuration.md: -------------------------------------------------------------------------------- 1 | # func ParseDuration(s string) (Duration, error) 2 | 3 | 参数列表: 4 | - s 时间长短的字符串 5 | 6 | 返回值: 7 | - Duration 解析后的时间长短 8 | - error 错误 9 | 10 | 功能说明: 11 | 12 | 将一个表示时间的字符串解析,每一个字符串是带有单位的十进制数序列,每个数字带有可选的单位或小数位。 13 | 合法的单位是"ns", "us" (or "µs"), "ms", "s", "m", "h"。 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "time" 22 | ) 23 | 24 | func main() { 25 | d, err := time.ParseDuration("1h2m3s4ms5.8us6ns") 26 | fmt.Printf("%v %v", d, err) 27 | } 28 | -------------------------------------------------------------------------------- /time/ParseError.md: -------------------------------------------------------------------------------- 1 | #type ParseError struct{} 2 | 3 | 描述时间转换错误 -------------------------------------------------------------------------------- /time/Seconds.md: -------------------------------------------------------------------------------- 1 | # func (d Duration) Seconds() float64 2 | 3 | 参数列表: 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - float64 10 | 11 | 功能说明: 12 | 13 | 返回时间d以秒为单位的浮点数形式 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "time" 22 | ) 23 | 24 | func main() { 25 | d, _ := time.ParseDuration("3h4m2s") 26 | fmt.Println(d.Seconds()) 27 | } 28 | -------------------------------------------------------------------------------- /time/Since.md: -------------------------------------------------------------------------------- 1 | # func Since(t Time) Duration 2 | 3 | 参数列表: 4 | 5 | - t 时间 6 | 7 | 返回值: 8 | 9 | - Duration 10 | 11 | 功能说明: 12 | 13 | 返回从时间t到当前时间的间隔,time.Now().Sub(t)的简写 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "time" 22 | ) 23 | 24 | func main() { 25 | t := time.Now() 26 | time.Sleep(3 * time.Second) 27 | fmt.Println(time.Since(t)) 28 | } 29 | -------------------------------------------------------------------------------- /time/Sleep.md: -------------------------------------------------------------------------------- 1 | # func Sleep(d Duration) 2 | 3 | 参数列表: 4 | 5 | - d 时间跨度 6 | 7 | 返回值: 8 | 9 | - 无 10 | 11 | 功能说明: 12 | 13 | 使当前goroutine暂停指定时间 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "time" 21 | ) 22 | 23 | func main() { 24 | time.Sleep(100 * time.Millisecond) 25 | } 26 | -------------------------------------------------------------------------------- /time/Sub.md: -------------------------------------------------------------------------------- 1 | # func (t Time) Sub(u Time) Duration 2 | 3 | 参数列表: 4 | 5 | - u 6 | 7 | 返回值: 8 | 9 | - Duration 10 | 11 | 功能说明: 12 | 13 | 返回t - u 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import( 20 | "fmt" 21 | "time" 22 | ) 23 | 24 | func main() { 25 | t1 := time.Now() 26 | time.Sleep(3 * time.Second) 27 | t2 := time.Now() 28 | fmt.Println(t2.Sub(t1)) 29 | } -------------------------------------------------------------------------------- /time/Tick.md: -------------------------------------------------------------------------------- 1 | # func Tick(d Duration) <-chan Time 2 | 3 | 参数列表: 4 | 5 | - d 时间跨度 6 | 7 | 返回值: 8 | 9 | - 返回Time chan 10 | 11 | 功能说明: 12 | 13 | Tick 是对NewTicker更易用的包装,提供了对定时器channel的访问。通常用于没必要停止定时器的客户端。 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "time" 22 | ) 23 | 24 | func main() { 25 | c := time.Tick(1 * time.Second) 26 | for now := range c { 27 | fmt.Printf("%v\n", now) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /time/Ticker.md: -------------------------------------------------------------------------------- 1 | # type Ticker struct { 2 | # C <-chan Time 3 | # } 4 | 5 | 保存一个同步的channel,每隔一个时钟间隔发出一个Tick -------------------------------------------------------------------------------- /time/Timer.md: -------------------------------------------------------------------------------- 1 | # type Timer Struct { 2 | # C <-Time 3 | # } 4 | 5 | 代表一个单独的事件,当时间过期的时候,把当前的时间发送给C,除非Timer是由[AfterFunc](AfterFunc.md)创建的。 6 | 7 | -------------------------------------------------------------------------------- /time/UTC.md: -------------------------------------------------------------------------------- 1 | # func (t Time) UTC() Time 2 | 3 | 参数列表: 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - Time 10 | 11 | 功能说明: 12 | 13 | 等价于 t.In(time.UTC) 14 | 15 | 代码实例: 16 | 17 | 无 -------------------------------------------------------------------------------- /time/UnixNano.md: -------------------------------------------------------------------------------- 1 | # func (t Time)UnixNano() int64 2 | 3 | 参数列表: 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - int64 10 | 11 | 功能说明: 12 | 13 | 返回t从January 1, 1970 UTC开始的Unix时间的纳秒数,如果纳秒数不能用int64来表示则结果是未定义的。注意:这意味着时间零点的UnixNano结果是未定义的。 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "time" 22 | ) 23 | 24 | func main() { 25 | now := time.Now() 26 | fmt.Println(now.UnixNano()) 27 | } -------------------------------------------------------------------------------- /time/UnmarshalJSON.md: -------------------------------------------------------------------------------- 1 | # func (t *Time) UnmarshalJSON(data []byte) (err error) 2 | 3 | 参数列表: 4 | 5 | - data json数据 6 | 7 | 返回值: 8 | 9 | - err 错误 10 | 11 | 功能说明: 12 | 13 | UnmarshalJSON实现了json.Unmarshaler接口。t按照RFC3339格式化。 14 | 15 | 代码实例: 16 | 17 | 无 -------------------------------------------------------------------------------- /time/Weekday.md: -------------------------------------------------------------------------------- 1 | # type Weekday int 2 | 3 | 指定一周中的一天(Sunday = 0, …) 4 | 5 | 常量: 6 | 7 | - Sunday Weekday = iota 8 | - Monday 9 | - Tuesday 10 | - Wednesday 11 | - Thursday 12 | - Friday 13 | - Saturday 14 | 15 | -------------------------------------------------------------------------------- /time/Zone.md: -------------------------------------------------------------------------------- 1 | # func (t Time) Zone() (name string, offset int) 2 | 3 | 参数列表: 4 | 5 | - 无 6 | 7 | 返回值: 8 | 9 | - name 时区简写 10 | - offset 相对与UTC向东的秒偏移 11 | 12 | 功能说明: 13 | 14 | package main 15 | 16 | import ( 17 | "fmt" 18 | "time" 19 | ) 20 | 21 | func main() { 22 | fmt.Println(time.Now().Zone()) 23 | } 24 | -------------------------------------------------------------------------------- /unicode/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /unicode/utf16/Decode.md: -------------------------------------------------------------------------------- 1 | # func Decode(s []uint16) []rune 2 | 3 | 函数列表 4 | 5 | - s utf-16序列 6 | 7 | 返回值: 8 | 9 | - 成功返回 Unicode 字符串 10 | 11 | 功能说明: 12 | 13 | >将utf-16序列 解码成Unicode字符序列并返回 14 | 15 | 代码实例: 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "unicode/utf16" 22 | ) 23 | func main() { 24 | u := []uint16{72, 101, 108, 108, 111, 32, 19990, 30028} 25 | s := utf16.Decode(u) 26 | fmt.Printf("%c", s) 27 | // [H e l l o 世 界] 28 | } 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /unicode/utf16/DecodeRune.md: -------------------------------------------------------------------------------- 1 | # func DecodeRune(r1, r2 runc) rune 2 | 3 | 参数列表: 4 | 5 | - r1 是utf-16代理对的高位码元 6 | - r2 是utf-16代理对的低位码元 7 | 8 | 9 | 返回值列表: 10 | 11 | - 返回值为解码后的 Unicode字符 12 | - 如果r1 或者 r2不是有效的utf-16代理区字符 13 | - 则返回 U+FFFD 14 | 15 | 功能说明: 16 | 17 | >将utf-16代理对解码成一个Unicode字符 18 | 19 | 实例代码: 20 | 21 | package main 22 | 23 | import ( 24 | "fmt" 25 | "unicode/utf16" 26 | ) 27 | func main() { 28 | r := utf16.DecodeRune(0xDBFC, 0xDC00) 29 | fmt.Printf("%U", r) 30 | // U+10F000 31 | } 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /unicode/utf16/Encode.md: -------------------------------------------------------------------------------- 1 | # func Encode(s []rune) []utf16 2 | 3 | 参数列表: 4 | 5 | -s Unicode 编码序列 6 | 7 | 返回值列表: 8 | 9 | - 返回utf16序列串 10 | 11 | 功能说明: 12 | 13 | >将 s 编码成 UTF-16 序列并返回 14 | 15 | 16 | 实例代码: 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "unicode/utf16" 22 | ) 23 | func main() { 24 | s := []rune("Hello 世界") 25 | u := utf16.Encode(s) 26 | fmt.Printf("%v", u) 27 | // [72 101 108 108 111 32 19990 30028] 28 | } 29 | 30 | -------------------------------------------------------------------------------- /unicode/utf16/README.md: -------------------------------------------------------------------------------- 1 | # utf16 包函数列表 2 | 3 | - [func Decode(s []utf16) []rune](Decode.md) 4 | - [func DecodeRune(r1, r2 rune) rune](DecodeRune.md) 5 | - [func Encode( []rune) []utf16](Encode.md) 6 | - [func EncodeRune( r rune) (r1 rune, r2 rune)](EncodeRune.md) 7 | - [func IsSurrogate(r rune) bool](IsSurrogate.md) 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /unicode/utf8/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 -------------------------------------------------------------------------------- /unsafe/README.md: -------------------------------------------------------------------------------- 1 | # 包名 2 | 3 | 函数列表 4 | 5 | - xxx1 6 | - xxx2 --------------------------------------------------------------------------------