Skip to content

Commit

Permalink
Merge pull request #12 from nighca/goplus
Browse files Browse the repository at this point in the history
Support Add / Remove Struct Tags
  • Loading branch information
xushiwei authored Oct 24, 2023
2 parents 0c97f91 + 9251172 commit 1f067fc
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion docs/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ This tool provides the information needed to compute the various test code lense

This tool provides support for the [`Go: Run on Go Playground`](features.md#go-playground) command.

### [`gomodifytags`](https://pkg.go.dev/github.com/fatih/gomodifytags?tab=overview)
### [`gopmodifytags`](https://pkg.go.dev/github.com/goplus/gopmodifytags?tab=overview)

This tool provides support for the [`Go: Add Tags to Struct Fields`](features.md#add-or-remove-struct-tags) and [`Go: Remove Tags From Struct Fields`](features.md#add-or-remove-struct-tags) commands.

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,12 @@
{
"command": "gop.add.tags",
"title": "Go+: Add Tags To Struct Fields",
"description": "Add tags configured in go.addTags setting to selected struct using gomodifytags"
"description": "Add tags configured in go.addTags setting to selected struct using gopmodifytags"
},
{
"command": "gop.remove.tags",
"title": "Go+: Remove Tags From Struct Fields",
"description": "Remove tags configured in go.removeTags setting from selected struct using gomodifytags"
"description": "Remove tags configured in go.removeTags setting from selected struct using gopmodifytags"
},
{
"command": "gop.fill.struct",
Expand Down
8 changes: 4 additions & 4 deletions src/goModifytags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function getCommonArgs(): string[] {
vscode.window.showInformationMessage('No editor is active.');
return [];
}
if (!editor.document.fileName.endsWith('.go')) {
if (!editor.document.fileName.endsWith('.go') && !editor.document.fileName.endsWith('.gop')) {
vscode.window.showInformationMessage('Current file is not a Go file.');
return [];
}
Expand Down Expand Up @@ -162,22 +162,22 @@ function getTagsAndOptions(config: GoTagsConfig, commandArgs: GoTagsConfig): The
}

function runGomodifytags(args: string[]) {
const gomodifytags = getBinPath('gomodifytags');
const gomodifytags = getBinPath('gopmodifytags');
const editor = vscode.window.activeTextEditor;
if (!editor) {
return;
}
const input = getFileArchive(editor.document);
const p = cp.execFile(gomodifytags, args, { env: toolExecutionEnvironment() }, (err, stdout, stderr) => {
if (err && (<any>err).code === 'ENOENT') {
promptForMissingTool('gomodifytags');
promptForMissingTool('gopmodifytags');
return;
}
if (err && (<any>err).code === 2 && args.indexOf('--template') > 0) {
vscode.window.showInformationMessage(
'Cannot modify tags: you might be using a' + 'version that does not support --template'
);
promptForUpdatingTool('gomodifytags');
promptForUpdatingTool('gopmodifytags');
return;
}
if (err) {
Expand Down
2 changes: 1 addition & 1 deletion src/goTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export function getConfiguredTools(
'guru',
'gorename',
'gotests',
'gomodifytags',
'gopmodifytags',
'impl',
'fillstruct',
'goplay',
Expand Down
10 changes: 5 additions & 5 deletions src/goToolsInformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ export const allToolsInformation: { [key: string]: Tool } = {
isImportant: false,
description: 'Rename symbols'
},
'gomodifytags': {
name: 'gomodifytags',
importPath: 'github.com/fatih/gomodifytags',
modulePath: 'github.com/fatih/gomodifytags',
'gopmodifytags': {
name: 'gopmodifytags',
importPath: 'github.com/goplus/gopmodifytags',
modulePath: 'github.com/goplus/gopmodifytags',
replacedByGopls: false,
isImportant: false,
description: 'Modify tags on structs',
defaultVersion: 'v1.16.0'
defaultVersion: 'v1.0.0'
},
'goplay': {
name: 'goplay',
Expand Down
10 changes: 5 additions & 5 deletions tools/allTools.ts.in
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ export const allToolsInformation: { [key: string]: Tool } = {
isImportant: false,
description: 'Rename symbols'
},
'gomodifytags': {
name: 'gomodifytags',
importPath: 'github.com/fatih/gomodifytags',
modulePath: 'github.com/fatih/gomodifytags',
'gopmodifytags': {
name: 'gopmodifytags',
importPath: 'github.com/goplus/gopmodifytags',
modulePath: 'github.com/goplus/gopmodifytags',
replacedByGopls: false,
isImportant: false,
description: 'Modify tags on structs',
defaultVersion: 'v1.16.0'
defaultVersion: 'v1.0.0'
},
'goplay': {
name: 'goplay',
Expand Down

0 comments on commit 1f067fc

Please sign in to comment.