Skip to content

Commit

Permalink
fix: fix an issue where the package name can't be set
Browse files Browse the repository at this point in the history
  • Loading branch information
shawdongGithub committed Oct 15, 2022
1 parent be3474f commit a44ea43
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ class Visitor {
return ` "${packageName}"`;
}
}).join('\n');
// 从darafile中读取packageName当做作为包名, 并非darafile中的package字段。为保持兼容设置client默认值
this.packageName = option.go && option.go.packageName ? option.go.packageName : 'client';
this.config = {
outputDir: '',
indent: ' ',
clientPath: '/client/client.go',
clientPath: `/${this.packageName}/client.go`,
...option
};
this.output = '';
Expand Down Expand Up @@ -2178,7 +2180,7 @@ class Visitor {
if (this.exec) {
this.emit(`package main\n\n`);
} else {
this.emit(`package client\n\n`);
this.emit(`package ${this.packageName}\n\n`);
}
this.emit(`import (\n`);
if (this.exec) {
Expand Down

0 comments on commit a44ea43

Please sign in to comment.