github.com/bir3/gocompiler@v0.9.2202/src/cmd/compile/internal/base/mapfile_read.go (about) 1 // Copyright 2018 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris 6 7 package base 8 9 import ( 10 "io" 11 "os" 12 ) 13 14 func MapFile(f *os.File, offset, length int64) (string, error) { 15 buf := make([]byte, length) 16 _, err := io.ReadFull(io.NewSectionReader(f, offset, length), buf) 17 if err != nil { 18 return "", err 19 } 20 return string(buf), nil 21 }