github.com/gitbundle/modules@v0.0.0-20231025071548-85b91c5c3b01/analyze/generated.go (about) 1 // Copyright 2023 The GitBundle Inc. All rights reserved. 2 // Copyright 2017 The Gitea Authors. All rights reserved. 3 // Use of this source code is governed by a MIT-style 4 // license that can be found in the LICENSE file. 5 6 package analyze 7 8 import ( 9 "path/filepath" 10 "strings" 11 12 "github.com/go-enry/go-enry/v2/data" 13 ) 14 15 // IsGenerated returns whether or not path is a generated path. 16 func IsGenerated(path string) bool { 17 ext := strings.ToLower(filepath.Ext(path)) 18 if _, ok := data.GeneratedCodeExtensions[ext]; ok { 19 return true 20 } 21 22 for _, m := range data.GeneratedCodeNameMatchers { 23 if m(path) { 24 return true 25 } 26 } 27 28 return false 29 }