V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
wencan
V2EX  ›  Visual Studio Code

求个 vscode go 自动加 tag 和注释的办法

  •  
  •   wencan · 2022 年 12 月 16 日 · 4457 次点击
    这是一个创建于 1128 天前的主题,其中的信息可能已经有所发展或是发生改变。

    比如,写个字段

    // Name 名称。
    Name string `json:"name"`
    

    期望是,写了“Name string”,自动补上 “名称。”之外的部分。

    16 条回复    2023-01-24 11:40:14 +08:00
    wuzhewuyou
        1
    wuzhewuyou  
       2022 年 12 月 16 日 via Android
    写到吐,吐着吐着也就习惯了
    idblife
        2
    idblife  
       2022 年 12 月 16 日
    github copilot ?
    jenlors
        3
    jenlors  
       2022 年 12 月 16 日
    Goland
    FrankFang128
        4
    FrankFang128  
       2022 年 12 月 16 日
    copilot
    wencan
        5
    wencan  
    OP
       2022 年 12 月 16 日
    @idblife
    @FrankFang128
    copilot 60 天试用啊
    janxin
        6
    janxin  
       2022 年 12 月 16 日
    @wencan 花钱 or 贡献开源项目
    vvhhaaattt
        7
    vvhhaaattt  
       2022 年 12 月 16 日 via Android
    https://app.quicktype.io/ 用 json 转 go struct 也是一个方法。
    ssjmhyvi
        8
    ssjmhyvi  
       2022 年 12 月 16 日
    securityCoding
        9
    securityCoding  
       2022 年 12 月 16 日 via Android
    换 goland 或者 copilot
    bandian
        10
    bandian  
       2022 年 12 月 16 日 via iPhone
    试试 maxnatchanon.go-struct-tag-autogen ,目前正在用,需要稍微配置一下,效果还可以
    bandian
        11
    bandian  
       2022 年 12 月 16 日 via iPhone
    可以实现输入 Name string `j 补全后面的部分
    LukeEuler
        12
    LukeEuler  
       2022 年 12 月 16 日
    官方 golang 插件: https://marketplace.visualstudio.com/items?itemName=golang.Go

    命令:Go: Add Tags To Struct Fields

    至于注释,我就不知道了
    Slurp
        13
    Slurp  
       2022 年 12 月 17 日 via iPad
    这种应该可以 snippet… IDEA 上类似的有 live template 。不过说到底是 Go 编译时特性不足,隔壁 Rust 只用在 struct 头上写一次就行…
    zzhzero
        14
    zzhzero  
       2022 年 12 月 17 日
    我以为这种 goland 的基础功能 vscode 早就有插件实现了
    yaott2020
        15
    yaott2020  
       2023 年 1 月 24 日 via Android
    说实话,不喜欢用 vscode 写 go 就是自动不全太烂了
    yaott2020
        16
    yaott2020  
       2023 年 1 月 24 日 via Android
    不如用 goland
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   2788 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 12:26 · PVG 20:26 · LAX 04:26 · JFK 07:26
    ♥ Do have faith in what you're doing.