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 !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd
     6  // +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd
     7  
     8  package base
     9  
    10  import (
    11  	"io"
    12  	"os"
    13  )
    14  
    15  func MapFile(f *os.File, offset, length int64) (string, error) {
    16  	buf := make([]byte, length)
    17  	_, err := io.ReadFull(io.NewSectionReader(f, offset, length), buf)
    18  	if err != nil {
    19  		return "", err
    20  	}
    21  	return string(buf), nil
    22  }
    23  

View as plain text