Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix an issue where the package name can't be set #87

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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