The Go Programming Language
› http://golang.org/
› Go Playground
Go Projects
› Revel Web Framework
Felldeadbird

vscode 如何格式化 go 中 map 对齐?

  •  
  •   Felldeadbird · Mar 20, 2024 · 2226 views
    This topic created in 966 days ago, the information mentioned may be changed or developed.

    写的 map 没有对齐冒号,代码写起来很不舒服.网上搜索了一些教程,都没起作用的。

    6 replies  •  2024-03-21 09:42:59 +08:00
    winterpotato
    winterpotato
    Mar 20, 2024
    1
    go fmt 可以满足吗?
    zzhaolei
    zzhaolei
    Mar 20, 2024
    2
    go fmt 不行的化请用 gofumpt
    ```
    "gopls": {
    "formatting.gofumpt": true,
    },
    ```
    body007
    body007
    Mar 20, 2024
    3
    我用 goimports
    Trim21
    Trim21
    Mar 20, 2024 via Android
    4
    vscode 默认用的是 go fmt 吧,应该是会对齐的?
    Felldeadbird
    Felldeadbird
    OP
    Mar 21, 2024
    5
    @Trim21 没。如果是 params := map[string]string{ 这里写参数 } 这种形式是不会对齐的。
    sztink
    sztink
    Mar 21, 2024
    6
    最好不要标新求异,go 开发统一都是 gofmt 或者 goimports(本质包含了 gofmt 功能),除非团队成员统一第三方插件,要不然同一份代码啥都没改,但由于不同的 formater 的自动 fmt 导致产生了新的变更。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2072 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 15:01 · PVG 23:01 · LAX 07:01 · JFK 10:01
    ♥ Do have faith in what you're doing.