mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-19 17:59:05 -05:00
Fix linting on Windows (#3457)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com> Signed-off-by: Diógenes Fernandes <diofeher@gmail.com> Co-authored-by: Martin Atkins <mart@degeneration.co.uk>
This commit is contained in:
committed by
GitHub
parent
ffc9c4d556
commit
530e5c4538
3
.gitignore
vendored
3
.gitignore
vendored
@@ -23,6 +23,9 @@ website/node_modules
|
||||
website/vendor
|
||||
vendor/
|
||||
|
||||
# "make golangci-lint" places its temprary golangci-lint executable here
|
||||
tools/golangci-lint*
|
||||
|
||||
# VSCode debugging configurations
|
||||
.vscode/launch.json
|
||||
|
||||
|
||||
6
Makefile
6
Makefile
@@ -46,10 +46,12 @@ generate:
|
||||
protobuf:
|
||||
go run ./tools/protobuf-compile .
|
||||
|
||||
# Golangci-lint
|
||||
# Golangci-lint is installed first and then run twice to cover all platforms.
|
||||
.PHONY: golangci-lint
|
||||
golangci-lint:
|
||||
go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.0 run --timeout 60m ./...
|
||||
GOBIN=$(PWD)/tools go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.0
|
||||
GOOS=windows tools/golangci-lint${EXT} run --timeout 60m ./...
|
||||
GOOS=linux tools/golangci-lint${EXT} run --timeout 60m ./...
|
||||
|
||||
# Run license check
|
||||
.PHONY: license-check
|
||||
|
||||
@@ -10,6 +10,7 @@ package flock
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"log"
|
||||
"math"
|
||||
"os"
|
||||
"syscall"
|
||||
@@ -40,7 +41,12 @@ func Lock(f *os.File) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer syscall.CloseHandle(ol.HEvent)
|
||||
defer func() {
|
||||
err := syscall.CloseHandle(ol.HEvent)
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] failed to close file locking event handle: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
return lockFileEx(
|
||||
syscall.Handle(f.Fd()),
|
||||
@@ -96,9 +102,8 @@ func Unlock(*os.File) error {
|
||||
}
|
||||
|
||||
func lockFileEx(h syscall.Handle, flags, reserved, locklow, lockhigh uint32, ol *syscall.Overlapped) (err error) {
|
||||
r1, _, e1 := syscall.Syscall6(
|
||||
r1, _, e1 := syscall.SyscallN(
|
||||
procLockFileEx.Addr(),
|
||||
6,
|
||||
uintptr(h),
|
||||
uintptr(flags),
|
||||
uintptr(reserved),
|
||||
@@ -136,9 +141,8 @@ func createEvent(sa *syscall.SecurityAttributes, manualReset bool, initialState
|
||||
_p1 = 1
|
||||
}
|
||||
|
||||
r0, _, e1 := syscall.Syscall6(
|
||||
r0, _, e1 := syscall.SyscallN(
|
||||
procCreateEventW.Addr(),
|
||||
4,
|
||||
uintptr(unsafe.Pointer(sa)),
|
||||
uintptr(_p0),
|
||||
uintptr(_p1),
|
||||
|
||||
@@ -29,17 +29,17 @@ func AtomicRename(source, destination string) error {
|
||||
// existing file.
|
||||
srcPtr, err := syscall.UTF16PtrFromString(source)
|
||||
if err != nil {
|
||||
return &os.LinkError{"replace", source, destination, err}
|
||||
return &os.LinkError{Op: "replace", Old: source, New: destination, Err: err}
|
||||
}
|
||||
destPtr, err := syscall.UTF16PtrFromString(destination)
|
||||
if err != nil {
|
||||
return &os.LinkError{"replace", source, destination, err}
|
||||
return &os.LinkError{Op: "replace", Old: source, New: destination, Err: err}
|
||||
}
|
||||
|
||||
flags := uint32(windows.MOVEFILE_REPLACE_EXISTING | windows.MOVEFILE_WRITE_THROUGH)
|
||||
err = windows.MoveFileEx(srcPtr, destPtr, flags)
|
||||
if err != nil {
|
||||
return &os.LinkError{"replace", source, destination, err}
|
||||
return &os.LinkError{Op: "replace", Old: source, New: destination, Err: err}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ const CP_UTF8 = 65001
|
||||
// interface.)
|
||||
|
||||
func SetConsoleCP(codepageID uint32) (err error) {
|
||||
r1, _, e1 := syscall.Syscall(procSetConsoleCP.Addr(), 1, uintptr(codepageID), 0, 0)
|
||||
r1, _, e1 := syscall.SyscallN(procSetConsoleCP.Addr(), uintptr(codepageID), 0, 0)
|
||||
if r1 == 0 {
|
||||
err = e1
|
||||
}
|
||||
@@ -150,7 +150,7 @@ func SetConsoleCP(codepageID uint32) (err error) {
|
||||
}
|
||||
|
||||
func SetConsoleOutputCP(codepageID uint32) (err error) {
|
||||
r1, _, e1 := syscall.Syscall(procSetConsoleOutputCP.Addr(), 1, uintptr(codepageID), 0, 0)
|
||||
r1, _, e1 := syscall.SyscallN(procSetConsoleOutputCP.Addr(), uintptr(codepageID), 0, 0)
|
||||
if r1 == 0 {
|
||||
err = e1
|
||||
}
|
||||
@@ -160,7 +160,3 @@ func SetConsoleOutputCP(codepageID uint32) (err error) {
|
||||
func staticTrue(f *os.File) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func staticFalse(f *os.File) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user