#rebuild github mod package to local

44 messages · Page 1 of 1 (latest)

mental iron
#

Hi, i want to make a change to a library from github, but i don't know if this the correct way or not. The library i use is https://github.com/sijms/go-ora

after i clone from git, i make change the go.mod

// module github.com/sijms/go-ora/v2
module go-ora-local

go 1.17

require golang.org/dl v0.0.0-20230616140434-092be8a72776 // indirect

but then all the file will have error could not import from github.com/sijms/go-ora/v2

currently i manuall change the import package of each file. Is there any idioms way to do this ? thank you

swift epoch
#

do not change the module name to something else

#

that's the most simple solution

swift epoch
mental iron
#

if i don't change it, then it produce error could not import from github.com/sijms/go-ora/v2 , which is actually this source code itself

swift epoch
#

if you don't change the codes

#

use go get instead git clone

mental iron
mental iron
mental iron
#

is it similar to mod replace ?

swift epoch
#

yes, but only at your localhost

mental iron
#

so basicly, when we're contributing to library, we can't just git clone and the mod magicly auto format the import ? but we still need to tweak the mod with replace / go.work ?
(sorry, this is my first time in the world of open source contributing)

swift epoch
#

I'm not a advanced contributer in go, so Idk. And I reject the go.work idea I said, it's not for your case. Basicly, the package shouldn't have error when you run go test with the package installed anywhere, so I think you should just contact the author? maybe?

mental iron
#

the package is working if you use go get. And it's actually fine

swift epoch
#

And remember to check your command, it should be go test /path/to/go-ora/v2

swift epoch
#

I mean, do not edit the package download from go get

swift epoch
mental iron
#

😭

swift epoch
#

The author made a bad folder structure, a go.mod shouldn't under another go.mod

mental iron
mental iron
swift epoch
#

if the main.go is not under go-ora/v2, you should use go.work then

mental iron
#

it's in another project. But the concern is not in my project

swift epoch
#

what's your project's go.mod

#

it could be your project issue

mental iron
#
module some_module
replace github.com/sijms/go-ora => ../go-ora
swift epoch
#

you should use replace github.com/sijms/go-ora/v2 => ../go-ora/v2

#

and never use replace now, use go.work instead

mental iron
#

no, even i replace it the v2, the local project itself is error

#

even go.work redirecting to my local go-ora/v2, the local go-ora/v2 itself is in error

swift epoch
#

I don't think you have to redirect in go.work

#

just use

go **

use (
  /path/to/go-ora/v2
  /path/to/your/project
)
mental iron
#

this is in my project. But the problem is not in my project, but the local library itself 😭

mental iron
#

no😭

#

i'm between laughing and crying here sir😭

swift epoch
#

well, if I have time later, I will taking this with you, but now I have other things todo

mental iron
#

okay, thank you for the time 🙏