Move C files to be included by go mod#885
Conversation
|
well, so much for this being easy 😞 I don't really understand the error here either, do you have any insight @shirou? |
|
oh hey that did the trick. I am a touch concerned that this would somehow still not work though 🤔 but my C seems to think that this should work |
|
I believe this breaks compatibility with non-darwin targets $ uname -a
Linux nzxt 5.4.0-33-generic #37-Ubuntu SMP Thu May 21 12:53:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux$ cat go.mod
module foo
go 1.14
replace github.com/shirou/gopsutil => github.com/afontaine/gopsutil v2.20.5-0.20200528220053-51e143da77b3+incompatible
require (
github.com/shirou/gopsutil v0.0.0-00010101000000-000000000000
golang.org/x/sys v0.0.0-20200523222454-059865788121 // indirect
)$ cat foo.go
package main
import _ "github.com/shirou/gopsutil/host"$ go build
foo.go:3:8: C source files not allowed when not using cgo or SWIG: smc.c
$ CGO_ENABLED=1 go build
foo.go:3:8: C source files not allowed when not using cgo or SWIG: smc.c |
|
Ah... yes, of course it's not that simple 🤔 |
…odules not including C files Supersedes shirou#885 by @afontaine
…odules not including C files Supersedes shirou#885 by @afontaine
|
You have to rename Though there were the same compilation warnings with these changes, I fixed them in my own branch (I'm quite sure I wouldn't be able to push to your branch) and took the occasion to rename darwin c files in the disk package. As you spent some time on it and want some attribution maybe, I can let you fix that in your branch and merge this PR afterwards, I will rebase my PR after merging yours if you do so. |
|
Ah the magic of go! Thanks @Lomanic I'm not super concerned about the attribution, more about the fix 😁 I updated the file names, and I don't really know what I'm doing with |
|
OK, no problem. |
Fixes #832 by moving the C files into a go module directory, which means they should be included by
go mod vendor.Not sure how I should name them, let me know if you want it changed.