Skip to content

Commit

Permalink
Merge #11633
Browse files Browse the repository at this point in the history
11633: Minor cleanup in go codegen r=iwahbe a=iwahbe

<!--- 
Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. -->

Fixes # (issue)

## Checklist

<!--- Please provide details if the checkbox below is to be left unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the Pulumi Service,
then the service should honor older versions of the CLI where this change would not exist.
You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Service API version
  <!-- `@Pulumi` employees: If yes, you must submit corresponding changes in the service repo. -->


Co-authored-by: Ian Wahbe <ian@wahbe.com>
  • Loading branch information
bors[bot] and iwahbe committed Dec 13, 2022
2 parents 667fe60 + 721ced3 commit da23804
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions pkg/codegen/go/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,8 @@ func (pkg *pkgContext) tokenToType(tok string) string {

components := strings.Split(tok, ":")
contract.Assertf(len(components) == 3, "tok: %s", tok)
if pkg == nil {
panic(fmt.Errorf("pkg is nil. token %s", tok))
}
if pkg.pkg == nil {
panic(fmt.Errorf("pkg.pkg is nil. token %s", tok))
}
contract.Assertf(pkg != nil, "pkg is nil. token %s", tok)
contract.Assertf(pkg.pkg != nil, "pkg.pkg is nil. token %s", tok)

mod, name := pkg.tokenToPackage(tok), components[2]

Expand Down Expand Up @@ -235,7 +231,7 @@ func (pkg *pkgContext) tokenToType(tok string) string {
if alias, hasAlias := pkg.pkgImportAliases[path.Join(pkg.importBasePath, mod)]; hasAlias {
importPath = alias
} else {
importPath = strings.ReplaceAll(mod, "/", "")
importPath = mod[strings.IndexRune(mod, '/')+1:]
importPath = strings.ReplaceAll(importPath, "-", "")
}

Expand Down

0 comments on commit da23804

Please sign in to comment.