Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add init function for windows when double-clicked #332

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cmd/adder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"log/slog"
"net/http"
"os"
"syscall"

"go.uber.org/automaxprocs/maxprocs"

Expand All @@ -37,6 +38,13 @@
programName = "adder"
)

func init() {
// Windows-specific: allocate a new console when launched by double-click
kernel32 := syscall.NewLazyDLL("kernel32.dll")

Check failure on line 43 in cmd/adder/main.go

View workflow job for this annotation

GitHub Actions / lint

undefined: syscall.NewLazyDLL (typecheck)

Check failure on line 43 in cmd/adder/main.go

View workflow job for this annotation

GitHub Actions / go-test (1.22.x, ubuntu-latest)

undefined: syscall.NewLazyDLL

Check failure on line 43 in cmd/adder/main.go

View workflow job for this annotation

GitHub Actions / go-test (1.23.x, ubuntu-latest)

undefined: syscall.NewLazyDLL
procAllocConsole := kernel32.NewProc("AllocConsole")
procAllocConsole.Call()
}

func slogPrintf(format string, v ...any) {
slog.Info(fmt.Sprintf(format, v...))
}
Expand Down
Loading