use errors is

This commit is contained in:
Shreyas Goenka 2023-05-17 15:27:03 +02:00
parent 9a70861e4b
commit ecc07e893f
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
1 changed files with 2 additions and 4 deletions

View File

@ -1,6 +1,7 @@
package template package template
import ( import (
"errors"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -41,10 +42,7 @@ func generateDirectory(config map[string]any, parentDir, nameTempate string) (st
func generateFile(config map[string]any, parentDir, nameTempate, contentTemplate string) error { func generateFile(config map[string]any, parentDir, nameTempate, contentTemplate string) error {
// compute file content // compute file content
fileContent, err := executeTemplate(config, contentTemplate) fileContent, err := executeTemplate(config, contentTemplate)
// We do a substring match here because on errors the template library prepends if errors.Is(err, ErrSkipThisFile) {
// some additional information about the callsite from which the ErrSkipThisFile
// error was returned
if err != nil && strings.Contains(err.Error(), ErrSkipThisFile.Error()) {
return nil return nil
} }
if err != nil { if err != nil {