Source file src/cmd/compile/internal/base/mapfile_read.go
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 !unix 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 } 22