mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
chore(proto): golangci lint apply into proto
Signed-off-by: slasher <shenjie1@oppo.com>
This commit is contained in:
parent
1d84f74acd
commit
4ae8eb48e7
@ -15,7 +15,7 @@ popd
|
||||
|
||||
export PATH=$PATH:/go/bin
|
||||
|
||||
for subdir in blockcache storage cli lcnode
|
||||
for subdir in proto blockcache storage cli lcnode
|
||||
do
|
||||
pushd ${CurrentPath}/../../${subdir}
|
||||
go generate ./...
|
||||
|
||||
@ -999,12 +999,12 @@ type ClientReportLimitInfo struct {
|
||||
FactorMap map[uint32]*ClientLimitInfo
|
||||
Host string
|
||||
Status uint8
|
||||
reserved string
|
||||
_ string // reserved
|
||||
}
|
||||
|
||||
func NewClientReportLimitInfo() *ClientReportLimitInfo {
|
||||
return &ClientReportLimitInfo{
|
||||
FactorMap: make(map[uint32]*ClientLimitInfo, 0),
|
||||
FactorMap: make(map[uint32]*ClientLimitInfo),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1015,13 +1015,13 @@ type LimitRsp2Client struct {
|
||||
HitTriggerCnt uint8
|
||||
FactorMap map[uint32]*ClientLimitInfo
|
||||
Magnify map[uint32]uint32
|
||||
reserved string
|
||||
_ string // reserved
|
||||
}
|
||||
|
||||
func NewLimitRsp2Client() *LimitRsp2Client {
|
||||
limit := &LimitRsp2Client{
|
||||
FactorMap: make(map[uint32]*ClientLimitInfo, 0),
|
||||
Magnify: make(map[uint32]uint32, 0),
|
||||
FactorMap: make(map[uint32]*ClientLimitInfo),
|
||||
Magnify: make(map[uint32]uint32),
|
||||
}
|
||||
return limit
|
||||
}
|
||||
|
||||
@ -239,11 +239,6 @@ func (k *ExtentKey) MarshalBinaryExt(data []byte) {
|
||||
|
||||
// MarshalBinary marshals the binary format of the extent key.
|
||||
func (k *ExtentKey) MarshalBinary(v3 bool) ([]byte, error) {
|
||||
extLen := ExtentLength
|
||||
if v3 {
|
||||
extLen += ExtentVerFieldSize
|
||||
}
|
||||
|
||||
buf := bytes.NewBuffer(make([]byte, 0, ExtentLength))
|
||||
if err := binary.Write(buf, binary.BigEndian, k.FileOffset); err != nil {
|
||||
return nil, err
|
||||
|
||||
@ -122,7 +122,7 @@ type BatchDentries struct {
|
||||
|
||||
func NewBatchDentries() *BatchDentries {
|
||||
return &BatchDentries{
|
||||
dentries: make(map[uint64]*ScanDentry, 0),
|
||||
dentries: make(map[uint64]*ScanDentry),
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,6 +146,6 @@ func (f *BatchDentries) BatchGetAndClear() (map[uint64]*ScanDentry, []uint64) {
|
||||
for i := range f.dentries {
|
||||
inodes = append(inodes, i)
|
||||
}
|
||||
f.dentries = make(map[uint64]*ScanDentry, 0)
|
||||
f.dentries = make(map[uint64]*ScanDentry)
|
||||
return dentries, inodes
|
||||
}
|
||||
|
||||
@ -187,7 +187,7 @@ func ParseMountOptions(opts []MountOption, cfg *config.Config) {
|
||||
opts[i].value = v
|
||||
}
|
||||
}
|
||||
fmt.Println(fmt.Sprintf("keyword[%v] value[%v] type[%T]", opts[i].keyword, opts[i].value, v))
|
||||
fmt.Printf("keyword[%v] value[%v] type[%T]\n", opts[i].keyword, opts[i].value, v)
|
||||
|
||||
case int64:
|
||||
if opts[i].cmdlineValue != "" {
|
||||
@ -199,7 +199,7 @@ func ParseMountOptions(opts []MountOption, cfg *config.Config) {
|
||||
opts[i].value = v
|
||||
}
|
||||
}
|
||||
fmt.Println(fmt.Sprintf("keyword[%v] value[%v] type[%T]", opts[i].keyword, opts[i].value, v))
|
||||
fmt.Printf("keyword[%v] value[%v] type[%T]\n", opts[i].keyword, opts[i].value, v)
|
||||
|
||||
case bool:
|
||||
if opts[i].cmdlineValue != "" {
|
||||
@ -211,10 +211,10 @@ func ParseMountOptions(opts []MountOption, cfg *config.Config) {
|
||||
opts[i].value = v
|
||||
}
|
||||
}
|
||||
fmt.Println(fmt.Sprintf("keyword[%v] value[%v] type[%T]", opts[i].keyword, opts[i].value, v))
|
||||
fmt.Printf("keyword[%v] value[%v] type[%T]\n", opts[i].keyword, opts[i].value, v)
|
||||
|
||||
default:
|
||||
fmt.Println(fmt.Sprintf("keyword[%v] unknown type[%T]", opts[i].keyword, v))
|
||||
fmt.Printf("keyword[%v] unknown type[%T]\n", opts[i].keyword, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -707,14 +707,10 @@ func (p *Packet) MarshalHeader(out []byte) {
|
||||
if p.Opcode == OpRandomWriteVer || p.ExtentType&MultiVersionFlag > 0 {
|
||||
binary.BigEndian.PutUint64(out[util.PacketHeaderSize:util.PacketHeaderSize+8], p.VerSeq)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (p *Packet) IsVersionList() bool {
|
||||
if p.ExtentType&VersionListFlag == VersionListFlag {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return p.ExtentType&VersionListFlag == VersionListFlag
|
||||
}
|
||||
|
||||
// UnmarshalHeader unmarshals the packet header.
|
||||
@ -943,9 +939,6 @@ func (p *Packet) ReadFromConnWithVer(c net.Conn, timeoutSec int) (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
if p.Size < 0 {
|
||||
return syscall.EBADMSG
|
||||
}
|
||||
size := p.Size
|
||||
if p.IsReadOperation() && p.ResultCode == OpInitResultCode {
|
||||
size = 0
|
||||
@ -990,9 +983,6 @@ func (p *Packet) ReadFromConn(c net.Conn, timeoutSec int) (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
if p.Size < 0 {
|
||||
return syscall.EBADMSG
|
||||
}
|
||||
size := p.Size
|
||||
if (p.Opcode == OpRead || p.Opcode == OpStreamRead || p.Opcode == OpExtentRepairRead || p.Opcode == OpStreamFollowerRead) && p.ResultCode == OpInitResultCode {
|
||||
size = 0
|
||||
|
||||
@ -21,8 +21,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
actionRegexp = regexp.MustCompile("^action:((oss:(\\w+))|(posix:(\\w)+))$")
|
||||
actionPrefixRegexp = regexp.MustCompile("^action:((oss)|(posix)):")
|
||||
actionRegexp = regexp.MustCompile(`^action:((oss:(\w+))|(posix:(\w)+))$`)
|
||||
actionPrefixRegexp = regexp.MustCompile(`^action:((oss)|(posix)):`)
|
||||
)
|
||||
|
||||
type Action string
|
||||
@ -380,12 +380,12 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
permRegexp = regexp.MustCompile("^perm:((builtin:((.*/*)([^/]*):*)(Writable|ReadOnly))|(custom:(\\w)+))$")
|
||||
builtinPermRegexp = regexp.MustCompile("^perm:builtin:((.*/*)([^/]*):*)(Writable|ReadOnly)$")
|
||||
builtinWritablePermRegexp = regexp.MustCompile("^perm:builtin:((.*/*)([^/]*):*)Writable$")
|
||||
builtinReadOnlyPermRegexp = regexp.MustCompile("^perm:builtin:((.*/*)([^/]*):*)ReadOnly$")
|
||||
customPermRegexp = regexp.MustCompile("^perm:custom:(\\w)+$")
|
||||
subdirRegexp = regexp.MustCompile("((.*/*)([^/]*)):(Writable|ReadOnly)$")
|
||||
permRegexp = regexp.MustCompile(`^perm:((builtin:((.*/*)([^/]*):*)(Writable|ReadOnly))|(custom:(\w)+))$`)
|
||||
builtinPermRegexp = regexp.MustCompile(`^perm:builtin:((.*/*)([^/]*):*)(Writable|ReadOnly)$`)
|
||||
builtinWritablePermRegexp = regexp.MustCompile(`^perm:builtin:((.*/*)([^/]*):*)Writable$`)
|
||||
builtinReadOnlyPermRegexp = regexp.MustCompile(`^perm:builtin:((.*/*)([^/]*):*)ReadOnly$`)
|
||||
customPermRegexp = regexp.MustCompile(`^perm:custom:(\w)+$`)
|
||||
subdirRegexp = regexp.MustCompile(`((.*/*)([^/]*)):(Writable|ReadOnly)$`)
|
||||
)
|
||||
|
||||
func ParsePermission(value string) Permission {
|
||||
|
||||
@ -607,8 +607,8 @@ const initTmId = -1
|
||||
func NewTransactionInfo(timeout int64, txType uint32) *TransactionInfo {
|
||||
return &TransactionInfo{
|
||||
Timeout: timeout,
|
||||
TxInodeInfos: make(map[uint64]*TxInodeInfo, 0),
|
||||
TxDentryInfos: make(map[string]*TxDentryInfo, 0),
|
||||
TxInodeInfos: make(map[uint64]*TxInodeInfo),
|
||||
TxDentryInfos: make(map[string]*TxDentryInfo),
|
||||
TmID: initTmId,
|
||||
TxType: txType,
|
||||
State: TxStateInit,
|
||||
@ -616,10 +616,7 @@ func NewTransactionInfo(timeout int64, txType uint32) *TransactionInfo {
|
||||
}
|
||||
|
||||
func (txInfo *TransactionInfo) IsInitialized() bool {
|
||||
if txInfo.TxID != "" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return txInfo.TxID != ""
|
||||
}
|
||||
|
||||
func (txInfo *TransactionInfo) String() string {
|
||||
|
||||
@ -187,7 +187,6 @@ func (policy *UserPolicy) IsAuthorizedS3(volume, api string) bool {
|
||||
if builtinReadOnlyPermRegexp.MatchString(perm) && !contain(api, WriteS3Api) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@ -5,6 +5,9 @@ import (
|
||||
"runtime"
|
||||
)
|
||||
|
||||
//TODO: remove this later.
|
||||
//go:generate golangci-lint run --issues-exit-code=1 -D errcheck -E bodyclose .
|
||||
|
||||
var (
|
||||
Version string
|
||||
CommitID string
|
||||
|
||||
Loading…
Reference in New Issue
Block a user