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

一个利用 go 的简陋语法模仿 const 修饰的 linter

  •  
  •   lance6716 · Jul 23, 2022 · 2271 views
    This topic created in 1403 days ago, the information mentioned may be changed or developed.

    https://github.com/lance6716/k4Const

    如果变量名长得像 kInts,会在修改它时报错

    $ go vet -vettool=$(which k4const) ./...
    # awesomeProject
    ./main.go:239:5: write to const variable 'kInts'
    

    顺便请问大家,编译期有什么比较近似、轻量的方法,能发现 kInts 实参赋值给了非 k 开头的形参吗?昨天看了一下 go 自带的 callgraph 、SSA 等库,比较头秃

    2 replies    2022-07-30 19:27:51 +08:00
    lysS
        1
    lysS  
       Jul 23, 2022
    什么东西。。。
    kkeep
        2
    kkeep  
       Jul 30, 2022
    既然如此为什么不 const 呢?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3324 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 10:58 · PVG 18:58 · LAX 03:58 · JFK 06:58
    ♥ Do have faith in what you're doing.