mirror of
https://github.com/golang/go
synced 2024-11-19 00:34:40 -07:00
75713da896
Change-Id: Ie42835b835ed22fddbba187ab10d8c31019ff008 Reviewed-on: https://go-review.googlesource.com/c/tools/+/178097 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
30 lines
691 B
Go
30 lines
691 B
Go
// Copyright 2019 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package cache
|
|
|
|
import (
|
|
"io/ioutil"
|
|
|
|
"golang.org/x/tools/internal/lsp/source"
|
|
"golang.org/x/tools/internal/span"
|
|
)
|
|
|
|
// nativeFileSystem implements FileSystem reading from the normal os file system.
|
|
type nativeFileSystem struct{}
|
|
|
|
func (nativeFileSystem) ReadFile(uri span.URI) *source.FileContent {
|
|
r := &source.FileContent{URI: uri}
|
|
filename, err := uri.Filename()
|
|
if err != nil {
|
|
r.Error = err
|
|
return r
|
|
}
|
|
r.Data, r.Error = ioutil.ReadFile(filename)
|
|
if r.Error != nil {
|
|
r.Hash = hashContents(r.Data)
|
|
}
|
|
return r
|
|
}
|