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

Allow compiling and running the project on macOS and windows #1421

Closed
gabriel-vasile opened this issue Aug 2, 2023 · 5 comments
Closed

Allow compiling and running the project on macOS and windows #1421

gabriel-vasile opened this issue Aug 2, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@gabriel-vasile
Copy link
Contributor

gabriel-vasile commented Aug 2, 2023

Hi, I'm trying to run the project locally, on macos, and I'm having trouble.

To reproduce my problem, you can try compiling the project for macos/windows:

# GOOS=darwin GOARCH=arm64 go build cmd/*.go
GOOS=windows GOARCH=amd64 go build cmd/*.go

cmd/init.go:705:19: undefined: syscall.Utsname
cmd/init.go:712:20: undefined: syscall.Uname
cmd/settings.go:302:19: undefined: syscall.Utsname
cmd/settings.go:307:20: undefined: syscall.Uname

uname syscall is only available for linux in golang. This code does not compile on macos/windows:

listmonk/cmd/init.go

Lines 703 to 714 in a440b79

var (
mem runtime.MemStats
utsname syscall.Utsname
)
// Memory / alloc stats.
runtime.ReadMemStats(&mem)
// OS info.
if err := syscall.Uname(&utsname); err != nil {
lo.Printf("WARNING: error getting system info: %v", err)
}

A more portable way to write that bit of code is to use Utsname and Uname from the golang.org/x/sys/unix package, but that does not work for windows.

@gabriel-vasile gabriel-vasile added the enhancement New feature or request label Aug 2, 2023
@knadh knadh closed this as completed in dcb87a3 Aug 3, 2023
@knadh
Copy link
Owner

knadh commented Aug 3, 2023

Thanks for the PR. There was a broken import in it, which I've fixed and merged in a separate commit.

@gabriel-vasile
Copy link
Contributor Author

Ah sorry, there were two places where syscall.Uname is used:

  1. dcb87a3
  2. The code I linked in first message here

Second place is still blocking compilation on macos/win.

@anascann
Copy link

anascann commented Aug 4, 2023

hello, @knadh syscall is still blocking the compilation for mac OSX.

  1. https://github.com/knadh/listmonk/blob/master/cmd/init.go#L705
  2. https://github.com/knadh/listmonk/blob/master/cmd/init.go#L712

this is the place where system about info is getting initialized in app.about .

@knadh
Copy link
Owner

knadh commented Aug 6, 2023

Had to get rid of the field altogether! 104c4fc

@gabriel-vasile
Copy link
Contributor Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants