github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/go/internal/mmap/mmap.go (about)

     1  // Copyright 2011 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  // This package is a lightly modified version of the mmap code
     6  // in github.com/google/codesearch/index.
     7  
     8  // The mmap package provides an abstraction for memory mapping files
     9  // on different platforms.
    10  package mmap
    11  
    12  import (
    13  	"github.com/shogo82148/std/os"
    14  )
    15  
    16  // Data is mmap'ed read-only data from a file.
    17  // The backing file is never closed, so Data
    18  // remains valid for the lifetime of the process.
    19  type Data struct {
    20  	f    *os.File
    21  	Data []byte
    22  }
    23  
    24  // Mmap maps the given file into memory.
    25  func Mmap(file string) (Data, error)