internal/lsp/source: Use file:///C:/ on Windows file system

URI should be started with file:/// always.

Change-Id: I123e577d421de3e85dfec00596fbdb63c2231938
Reviewed-on: https://go-review.googlesource.com/c/153618
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Yasuhiro Matsumoto 2018-12-12 01:02:12 +09:00 коммит произвёл Rebecca Stambler
Родитель b620e9ecbe
Коммит 49db546f37
4 изменённых файлов: 44 добавлений и 2 удалений

Просмотреть файл

@ -12,8 +12,6 @@ import (
"strings"
)
const fileSchemePrefix = "file://"
// URI represents the full uri for a file.
type URI string

Просмотреть файл

@ -0,0 +1,9 @@
// Copyright 2018 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.
// +build !windows
package source
const fileSchemePrefix = "file://"

Просмотреть файл

@ -0,0 +1,9 @@
// Copyright 2018 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.
// +build windows
package source
const fileSchemePrefix = "file:///"

Просмотреть файл

@ -0,0 +1,26 @@
// Copyright 2018 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.
// +build windows
package source
import (
"testing"
)
func TestURIWindows(t *testing.T) {
s := `C:\Windows\System32`
uri := ToURI(s)
if uri != `file:///C:/Windows/System32` {
t.Fatalf("ToURI: got %v want %v", uri, s)
}
f, err := URI(uri).Filename()
if err != nil {
t.Fatal(err)
}
if f != s {
t.Fatalf("Filename: got %v want %v", f, s)
}
}