mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 08:26:00 +01:00
* Bump golang.org/x/text from 0.3.7 to 0.3.8 Bumps [golang.org/x/text](https://github.com/golang/text) from 0.3.7 to 0.3.8. - [Release notes](https://github.com/golang/text/releases) - [Commits](https://github.com/golang/text/compare/v0.3.7...v0.3.8) --- updated-dependencies: - dependency-name: golang.org/x/text dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Update go dependencies * Update x/net --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
47 lines
1,019 B
Go
47 lines
1,019 B
Go
package codegen
|
|
|
|
import (
|
|
"fmt"
|
|
"go/types"
|
|
"strings"
|
|
)
|
|
|
|
func findGoNamedType(def types.Type) (*types.Named, error) {
|
|
if def == nil {
|
|
return nil, nil
|
|
}
|
|
|
|
namedType, ok := def.(*types.Named)
|
|
if !ok {
|
|
return nil, fmt.Errorf("expected %s to be a named type, instead found %T\n", def.String(), def)
|
|
}
|
|
|
|
return namedType, nil
|
|
}
|
|
|
|
func findGoInterface(def types.Type) (*types.Interface, error) {
|
|
if def == nil {
|
|
return nil, nil
|
|
}
|
|
namedType, err := findGoNamedType(def)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if namedType == nil {
|
|
return nil, nil
|
|
}
|
|
|
|
underlying, ok := namedType.Underlying().(*types.Interface)
|
|
if !ok {
|
|
return nil, fmt.Errorf("expected %s to be a named interface, instead found %s", def.String(), namedType.String())
|
|
}
|
|
|
|
return underlying, nil
|
|
}
|
|
|
|
func equalFieldName(source, target string) bool {
|
|
source = strings.ReplaceAll(source, "_", "")
|
|
source = strings.ReplaceAll(source, ",omitempty", "")
|
|
target = strings.ReplaceAll(target, "_", "")
|
|
return strings.EqualFold(source, target)
|
|
}
|