mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
gofmt (#826)
This commit is contained in:
@ -298,7 +298,7 @@ func TestInvalidGlobIgnoredTarget(t *testing.T) {
|
||||
}
|
||||
}()
|
||||
|
||||
checkLengthsFull(t, existing, desired, 0, 1, 0, 0, false, nil, []*models.IgnoreTarget{{Pattern: "[.www3", Type: "CNAME"}} )
|
||||
checkLengthsFull(t, existing, desired, 0, 1, 0, 0, false, nil, []*models.IgnoreTarget{{Pattern: "[.www3", Type: "CNAME"}})
|
||||
}
|
||||
|
||||
func TestInvalidTypeIgnoredTarget(t *testing.T) {
|
||||
@ -317,7 +317,7 @@ func TestInvalidTypeIgnoredTarget(t *testing.T) {
|
||||
}
|
||||
}()
|
||||
|
||||
checkLengthsFull(t, existing, desired, 0, 1, 0, 0, false, nil, []*models.IgnoreTarget{{Pattern: "1.1.1.1", Type: "A"}} )
|
||||
checkLengthsFull(t, existing, desired, 0, 1, 0, 0, false, nil, []*models.IgnoreTarget{{Pattern: "1.1.1.1", Type: "A"}})
|
||||
}
|
||||
|
||||
// from https://github.com/StackExchange/dnscontrol/issues/552
|
||||
|
16
pkg/js/js.go
16
pkg/js/js.go
@ -120,8 +120,8 @@ func require(call otto.FunctionCall) otto.Value {
|
||||
|
||||
func listFiles(call otto.FunctionCall) otto.Value {
|
||||
// Check amount of arguments provided
|
||||
if ! (len(call.ArgumentList) >= 1 && len(call.ArgumentList) <= 3) {
|
||||
throw(call.Otto, "glob requires at least one argument: folder (string). " +
|
||||
if !(len(call.ArgumentList) >= 1 && len(call.ArgumentList) <= 3) {
|
||||
throw(call.Otto, "glob requires at least one argument: folder (string). "+
|
||||
"Optional: recursive (bool) [true], fileExtension (string) [.js]")
|
||||
}
|
||||
|
||||
@ -143,8 +143,8 @@ func listFiles(call otto.FunctionCall) otto.Value {
|
||||
}
|
||||
|
||||
// Second: Recursive?
|
||||
var recursive bool = true;
|
||||
if call.Argument(1).IsDefined() && ! call.Argument(1).IsNull() {
|
||||
var recursive bool = true
|
||||
if call.Argument(1).IsDefined() && !call.Argument(1).IsNull() {
|
||||
if call.Argument(1).IsBoolean() {
|
||||
recursive, _ = call.Argument(1).ToBoolean() // If it should be recursive
|
||||
} else {
|
||||
@ -153,11 +153,11 @@ func listFiles(call otto.FunctionCall) otto.Value {
|
||||
}
|
||||
|
||||
// Third: File extension filter.
|
||||
var fileExtension string = ".js";
|
||||
if call.Argument(2).IsDefined() && ! call.Argument(2).IsNull() {
|
||||
var fileExtension string = ".js"
|
||||
if call.Argument(2).IsDefined() && !call.Argument(2).IsNull() {
|
||||
if call.Argument(2).IsString() {
|
||||
fileExtension = call.Argument(2).String() // Which file extension to filter for.
|
||||
if ! strings.HasPrefix(fileExtension, ".") {
|
||||
if !strings.HasPrefix(fileExtension, ".") {
|
||||
// If it doesn't start with a dot, probably user forgot it and we do it instead.
|
||||
fileExtension = "." + fileExtension
|
||||
}
|
||||
@ -176,7 +176,7 @@ func listFiles(call otto.FunctionCall) otto.Value {
|
||||
// require() doesn't seem to handle well. For the sake of compatibility (and because slash looks nicer),
|
||||
// we simply replace "\\" to "/" using filepath.ToSlash()..
|
||||
path = filepath.ToSlash(filepath.Clean(path)) // convert to slashes for directories
|
||||
if ! recursive && fi.IsDir() {
|
||||
if !recursive && fi.IsDir() {
|
||||
// If recursive is disabled, it is a dir what we're processing, and the path is different
|
||||
// than specified, we're apparently in a different folder. Therefore: Skip it.
|
||||
// So: Why this way? Because Walk() is always recursive and otherwise would require a complete
|
||||
|
Reference in New Issue
Block a user