I am trying to use GoModifyTags but it's not giving me required result.
I have installed this as per the instruction but don't know how to implement. Using VScode editor.
I am trying to add bson tags in my file.
Currently, I have:
type option []struct {
Option string `json:"option"`
ID float64 `json:"id"`
Correct bool `json:"correct"`
}
Required:
type option []struct {
Option string `json:"option" bson:"option"`
ID float64 `json:"id" bson:"id"`
Correct bool `json:"correct" bson:"correct"`
}
How can I achieve this?
Solution:
Following the instruction of Jihoon Ye, I am able to get my required result. Here are steps for VSCode with pictures to help you understand better.
Go to File -> Preference -> Settings
Type "Go: Add Tags" in the search box and you will see the settings as below. Add bson in the tag field.
Select your go struct in the code
Right-click the selected code OR use command palette (use shortcut cntrl + shift + p) and select "Go: Add tags to struct fields"
Peace,
Using the command
install GoModifyTags.
Enter the command below.
The results below will then be printed out.
Using the VSCode
In user settings, setting "Go: Add Tags" as below.
Place the cursor in the structure and run "Go: Add Tags To Struct Field".