#[Clean code] Need a better way to import a C library in Golang

16 messages · Page 1 of 1 (latest)

elfin falcon
#

it depends what you want to do

#

the upside of writing tests in go is that you not only test the C code but the go shim around it too

acoustic valley
#

now for the static linking, is there any other cleaner way than write a 700 long line of linking in the go file ?

abstract blade
#

what's dirty about it?

acoustic valley
#

having a 700 character long line for the linking everytime we have to use the libraries

#

having to use absolute paths instead of dynamic paths

#

imagine i wanna move some libraries, i'll have to change all the paths from LDFLAGS

abstract blade
#

you don't need to repeat the flags for every file
in the screenshot the paths are relative
given they are relative you wouldn't need to, provided they are packaged in a cohesive way

#

plus, you'd only need to change it once

#

if you want some advice

don't solve imaginary problems

#

if you insist on solving what looks like, ostensibly, a non issue, using pkgconfig can help

#

at the cost of complicating the build if you plan on hosting the .pc out of the system path (which I'd wager you would)

elfin falcon
#

@acoustic valley make the C to CGO lib once

#

then have everyone import that go package

#

instead of everyone calling the C lib