Ptt-official-app / go-bbs

BBS file database manager system library in Golang.
Apache License 2.0
80 stars 43 forks source link

解決go lint上顯示的warning,包含縮寫及error命名、一致的receiver命名等 #54

Closed titaneric closed 3 years ago

titaneric commented 3 years ago

👏 解決掉的 issue / Resolved Issues

⛏ 變更內容 / Details of Changes

titaneric commented 3 years ago

準備可以review了,但CI好像有go build的問題要幫忙看一下

minchao commented 3 years ago

@titaneric CI 裡的問題是 #37 及 https://github.com/Ptt-official-app/go-bbs/pull/58#issuecomment-789741746 提到的 module declare,注意到 development 分支在剛剛已經修正了。

PichuChen commented 3 years ago

可以再幫我 pull 一次 development 嗎?

minchao commented 3 years ago

簡單在 merge current development 後的版本,透過 golangci-lint 跑 golint,發現幾個漏網之魚,提供參考:

$ golangci-lint run
cache/systemvshm.go:50:2: var `shmId` should be `shmID` (golint)
    shmId, err := Shmget(key, size, flag)
    ^
cache/systemvshm.go:95:2: var `shmId` should be `shmID` (golint)
    shmId, err := Shmget(key, 0, 0)
    ^
cache/systemvshm.go:112:1: receiver name m should be consistent with previous receiver name s for SHM (golint)
func (m *SHM) Close() error {
^
pttbbs/board.go:69:23: method BoardId should be BoardID (golint)
func (b *BoardHeader) BoardId() string            { return b.BoardID() }
                      ^
pttbbs/cache.go:14:2: struct field `posOfUserId` should be `posOfUserID` (golint)
    posOfUserId     int
    ^
pttbbs/cache.go:297:17: method UserId should be UserID (golint)
func (c *Cache) UserId(uid int) string {
                ^
titaneric commented 3 years ago

感謝 @minchao 與 @PichuChen ,目前CI過囉,再麻煩幫忙review

minchao commented 3 years ago

@titaneric 剩下最後一個 receiver 修改就過 lint 囉

% golangci-lint run
cache/systemvshm.go:112:1: receiver name m should be consistent with previous receiver name s for SHM (golint)
func (m *SHM) Close() error {
^