Black Lives Matter. Support the Equal Justice Initiative.

Source file src/cmd/compile/internal/typecheck/mapfile_read.go

Documentation: cmd/compile/internal/typecheck

     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 typecheck
     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