mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 11:07:40 +08:00
enable vet.
This commit is contained in:
parent
2d79fccd10
commit
061067bf95
3
.github/workflows/go.yml
vendored
3
.github/workflows/go.yml
vendored
@ -25,6 +25,9 @@ jobs:
|
||||
run: |
|
||||
go get -v -t -d ./...
|
||||
|
||||
- name: Vet
|
||||
run: go vet -stdmethods=false ./...
|
||||
|
||||
- name: Build
|
||||
run: go build -v ./...
|
||||
|
||||
|
13
utils/sys.go
13
utils/sys.go
@ -13,15 +13,18 @@ type multiReadSeeker struct {
|
||||
multiReader io.Reader
|
||||
}
|
||||
|
||||
func add(p unsafe.Pointer, x uintptr) unsafe.Pointer {
|
||||
return unsafe.Pointer(uintptr(p) + x)
|
||||
}
|
||||
|
||||
func IsChanClosed(ch interface{}) bool {
|
||||
if reflect.TypeOf(ch).Kind() != reflect.Chan {
|
||||
panic("object is not a channel.")
|
||||
}
|
||||
ptr := *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&ch)) + unsafe.Sizeof(uint(0))))
|
||||
ptr += unsafe.Sizeof(uint(0)) * 2
|
||||
ptr += unsafe.Sizeof(uintptr(0))
|
||||
ptr += unsafe.Sizeof(uint16(0))
|
||||
return *(*uint32)(unsafe.Pointer(ptr)) > 0
|
||||
return *(*uint32)(
|
||||
add(*(*unsafe.Pointer)(add(unsafe.Pointer(&ch), unsafe.Sizeof(uintptr(0)))),
|
||||
unsafe.Sizeof(uint(0))*2+unsafe.Sizeof(uintptr(0))+unsafe.Sizeof(uint16(0))),
|
||||
) > 0
|
||||
}
|
||||
|
||||
func ComputeMd5AndLength(r io.Reader) ([]byte, int64) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user