markdown-flashcards icon indicating copy to clipboard operation
markdown-flashcards copied to clipboard

fix windows calls of term.GetSize

Open eissar opened this issue 9 months ago • 2 comments

replace all occurrences of os.Stdin.Fd() with os.Stdout.Fd()

eissar avatar Apr 03 '25 02:04 eissar

I tried using the binaries in V2.0.0 and still was getting the same error as reported by @nimrossum in #9 . It looks like there was some misunderstanding as the program was building fine, but would not run.

The problem is this line: https://github.com/bttger/markdown-flashcards/blob/be6b4c377ba27a830c6daf805d01ddc2281f194e/internal/utils.go#L26

Not exactly sure why stdin doesn't work, I think it's something to do with the handle for stdin not being a file descriptor on windows or something? anyways there's an issue talking about it here: https://github.com/golang/go/issues/20388#issuecomment-302006236

I was able to get the program to run by changing those occurrences of os.Stdin.Fd() to os.Stdout.Fd() on my windows machine.

eissar avatar Apr 03 '25 02:04 eissar

second this!

I had issues getting the application to run on windows inside of MINGW64 (git bash terminal) I got the following error:

panic: The handle is invalid.

goroutine 1 [running]:
github.com/bttger/markdown-flashcards/internal.check(...)
        C:/Users/ZielM/projects/markdown-flashcards/internal/utils.go:35
github.com/bttger/markdown-flashcards/internal.ScrollDownScreen()
        C:/Users/ZielM/projects/markdown-flashcards/internal/utils.go:27 +0x86
github.com/bttger/markdown-flashcards/internal.(*Session).Start(0xc0000dfe28)
        C:/Users/ZielM/projects/markdown-flashcards/internal/leitner.go:71 +0x14b
main.main()
        C:/Users/ZielM/projects/markdown-flashcards/cmd/mdfc.go:146 +0x9b2

after trying out the suggested solution it worked like a charm!

sadly I'm not too familiar with go, so can't say anything about the correctness of the fix but the result looks fine.

Have a nice day :)

ZielMartin avatar Apr 09 '25 21:04 ZielMartin

Thank you for the PR! I was not able to test it under Windows, so thank you. Just checked out your branch and adapted my test file a bit and seems to still work fine on Linux. Will merge and release a patch version.

bttger avatar Jun 12 '25 13:06 bttger