From ca8eb1d421cbe4dbe6f80312b9cc6e1f9ed4a47c Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sat, 19 May 2018 05:56:02 -0400 Subject: [PATCH] privatize some methods --- deno_dir.go | 2 +- handlers.go | 6 +++--- util.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/deno_dir.go b/deno_dir.go index 8412889363..b3a8c78b91 100644 --- a/deno_dir.go +++ b/deno_dir.go @@ -28,7 +28,7 @@ func CacheFileName(filename string, sourceCodeBuf []byte) string { // Fetches a remoteUrl but also caches it to the localFilename. func FetchRemoteSource(remoteUrl string, localFilename string) ([]byte, error) { //println("FetchRemoteSource", remoteUrl) - Assert(strings.HasPrefix(localFilename, SrcDir), localFilename) + assert(strings.HasPrefix(localFilename, SrcDir), localFilename) var sourceReader io.Reader file, err := os.Open(localFilename) diff --git a/handlers.go b/handlers.go index 5f9470ab19..d653615957 100644 --- a/handlers.go +++ b/handlers.go @@ -36,7 +36,7 @@ func recv(buf []byte) []byte { } func HandleSourceCodeFetch(moduleSpecifier string, containingFile string) (out []byte) { - Assert(moduleSpecifier != "", "moduleSpecifier shouldn't be empty") + assert(moduleSpecifier != "", "moduleSpecifier shouldn't be empty") res := &Msg{} var sourceCodeBuf []byte var err error @@ -57,13 +57,13 @@ func HandleSourceCodeFetch(moduleSpecifier string, containingFile string) (out [ //println("HandleSourceCodeFetch", "moduleSpecifier", moduleSpecifier, // "containingFile", containingFile, "filename", filename) - if IsRemote(moduleName) { + if isRemote(moduleName) { sourceCodeBuf, err = FetchRemoteSource(moduleName, filename) } else if strings.HasPrefix(moduleName, assetPrefix) { f := strings.TrimPrefix(moduleName, assetPrefix) sourceCodeBuf, err = Asset("dist/" + f) } else { - Assert(moduleName == filename, + assert(moduleName == filename, "if a module isn't remote, it should have the same filename") sourceCodeBuf, err = ioutil.ReadFile(moduleName) } diff --git a/util.go b/util.go index 803260920f..3e0ac63746 100644 --- a/util.go +++ b/util.go @@ -4,13 +4,13 @@ import ( "net/url" ) -func Assert(cond bool, msg string) { +func assert(cond bool, msg string) { if !cond { panic(msg) } } -func IsRemote(filename string) bool { +func isRemote(filename string) bool { u, err := url.Parse(filename) check(err) return u.IsAbs()