// Copyright 2009 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.//go:build unix || (js && wasm) || wasip1package syscallimport ()// readInt returns the size-bytes unsigned integer in native byte order at offset off.func ( []byte, , uintptr) ( uint64, bool) {iflen() < int(+) {return0, false }ifisBigEndian {returnreadIntBE([:], ), true }returnreadIntLE([:], ), true}func ( []byte, uintptr) uint64 {switch {case1:returnuint64([0])case2: _ = [1] // bounds check hint to compiler; see golang.org/issue/14808returnuint64([1]) | uint64([0])<<8case4: _ = [3] // bounds check hint to compiler; see golang.org/issue/14808returnuint64([3]) | uint64([2])<<8 | uint64([1])<<16 | uint64([0])<<24case8: _ = [7] // bounds check hint to compiler; see golang.org/issue/14808returnuint64([7]) | uint64([6])<<8 | uint64([5])<<16 | uint64([4])<<24 |uint64([3])<<32 | uint64([2])<<40 | uint64([1])<<48 | uint64([0])<<56default:panic("syscall: readInt with unsupported size") }}func ( []byte, uintptr) uint64 {switch {case1:returnuint64([0])case2: _ = [1] // bounds check hint to compiler; see golang.org/issue/14808returnuint64([0]) | uint64([1])<<8case4: _ = [3] // bounds check hint to compiler; see golang.org/issue/14808returnuint64([0]) | uint64([1])<<8 | uint64([2])<<16 | uint64([3])<<24case8: _ = [7] // bounds check hint to compiler; see golang.org/issue/14808returnuint64([0]) | uint64([1])<<8 | uint64([2])<<16 | uint64([3])<<24 |uint64([4])<<32 | uint64([5])<<40 | uint64([6])<<48 | uint64([7])<<56default:panic("syscall: readInt with unsupported size") }}// ParseDirent parses up to max directory entries in buf,// appending the names to names. It returns the number of// bytes consumed from buf, the number of entries added// to names, and the new names slice.func ( []byte, int, []string) ( int, int, []string) { := len() = 0for != 0 && len() > 0 { , := direntReclen()if ! || > uint64(len()) {return , , } := [:] = [:] , := direntIno()if ! {break }// See src/os/dir_unix.go for the reason why this condition is // excluded on wasip1.if == 0 && runtime.GOOS != "wasip1" { // File absent in directory.continue }const = uint64(unsafe.Offsetof(Dirent{}.Name)) , := direntNamlen()if ! || + > uint64(len()) {break } := [ : +]for , := range {if == 0 { = [:]break } }// Check for useless names before allocating a string.ifstring() == "." || string() == ".." {continue } -- ++ = append(, string()) }return - len(), , }
The pages are generated with Goldsv0.6.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.