mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 19:17:38 +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: |
|
run: |
|
||||||
go get -v -t -d ./...
|
go get -v -t -d ./...
|
||||||
|
|
||||||
|
- name: Vet
|
||||||
|
run: go vet -stdmethods=false ./...
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: go build -v ./...
|
run: go build -v ./...
|
||||||
|
|
||||||
|
13
utils/sys.go
13
utils/sys.go
@ -13,15 +13,18 @@ type multiReadSeeker struct {
|
|||||||
multiReader io.Reader
|
multiReader io.Reader
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func add(p unsafe.Pointer, x uintptr) unsafe.Pointer {
|
||||||
|
return unsafe.Pointer(uintptr(p) + x)
|
||||||
|
}
|
||||||
|
|
||||||
func IsChanClosed(ch interface{}) bool {
|
func IsChanClosed(ch interface{}) bool {
|
||||||
if reflect.TypeOf(ch).Kind() != reflect.Chan {
|
if reflect.TypeOf(ch).Kind() != reflect.Chan {
|
||||||
panic("object is not a channel.")
|
panic("object is not a channel.")
|
||||||
}
|
}
|
||||||
ptr := *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&ch)) + unsafe.Sizeof(uint(0))))
|
return *(*uint32)(
|
||||||
ptr += unsafe.Sizeof(uint(0)) * 2
|
add(*(*unsafe.Pointer)(add(unsafe.Pointer(&ch), unsafe.Sizeof(uintptr(0)))),
|
||||||
ptr += unsafe.Sizeof(uintptr(0))
|
unsafe.Sizeof(uint(0))*2+unsafe.Sizeof(uintptr(0))+unsafe.Sizeof(uint16(0))),
|
||||||
ptr += unsafe.Sizeof(uint16(0))
|
) > 0
|
||||||
return *(*uint32)(unsafe.Pointer(ptr)) > 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ComputeMd5AndLength(r io.Reader) ([]byte, int64) {
|
func ComputeMd5AndLength(r io.Reader) ([]byte, int64) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user