blob: 758d63b79831f6aeb765a548b9e91d42a78dccfc [file] [log] [blame]
// Copyright 2022 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 govulnchecklib
import (
const noGoModErrorMessage = `govulncheck: no go.mod file
govulncheck only works Go with modules. To make your project a module, run go mod init.
See for more information.`
const noGoSumErrorMessage = `govulncheck: no go.sum file
Your module is missing a go.sum file. Try running go mod tidy.
See for more information.`
// fileExists checks if file path exists. Returns true
// if the file exists or it cannot prove that it does
// not exist. Otherwise, returns false.
func fileExists(path string) bool {
if _, err := os.Stat(path); err == nil {
return true
} else if errors.Is(err, os.ErrNotExist) {
return false
// Conservatively return true if os.Stat fails
// for some other reason.
return true