chore: fix lint

main
sudo pacman -Syu 2022-08-16 12:59:42 +07:00
parent 72f12c2533
commit ef6e0cd582
No known key found for this signature in database
GPG Key ID: D6CB5C6C567C47B0
1 changed files with 5 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package main
import ( import (
"embed" "embed"
"errors"
"fmt" "fmt"
"path/filepath" "path/filepath"
"strings" "strings"
@ -13,6 +14,8 @@ const (
templatesPath = "templates" templatesPath = "templates"
) )
var ErrInvalidLicense = errors.New("invalid license")
//go:embed templates/* //go:embed templates/*
var embedFS embed.FS var embedFS embed.FS
@ -35,13 +38,13 @@ type templateInfo struct {
func generateLicense(name string) (string, error) { func generateLicense(name string) (string, error) {
if name == "" { if name == "" {
return "", fmt.Errorf("empty license name") return "", fmt.Errorf("empty license name: %w", ErrInvalidLicense)
} }
name = strings.ToUpper(name) name = strings.ToUpper(name)
templateInfo, ok := templates[name] templateInfo, ok := templates[name]
if !ok { if !ok {
return "", fmt.Errorf("not support license %s", name) return "", fmt.Errorf("not support license %s: %w", name, ErrInvalidLicense)
} }
// Get correct path of license // Get correct path of license