Re: [go-nuts] Parsing go.mod
Not really exposed, but there is code you could copy. https://golang.org/pkg/cmd/go/internal/modfile/#Parse On Mon, 2019-09-02 at 22:44 -0700, James Pettyjohn wrote: > Hi, > > This might be a bad idea but I'm trying to parse the go.mod file for > data > as part of my build process - if at all possible I'd like to avoid > duplicating the data that is already there in another file. > > Is there an exposed package that can be used for this? > > - J > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/4d672a4c60b90b4552a5f5bf672e925f313cc942.camel%40kortschak.io.
Re: [go-nuts] Parsing go.mod
On Mon, Sep 2, 2019 at 10:44 PM James Pettyjohn wrote: > This might be a bad idea but I'm trying to parse the go.mod file for data > as part of my build process - if at all possible I'd like to avoid > duplicating the data that is already there in another file. > In this type of situation you should explain why you need to parse a go.mod file. Especially since you seem to be asking something not already asked a thousand times. It is possible, perhaps likely, the reason you want to do this can be solved some other way. -- Kurtis Rader Caretaker of the exceptional canines Junior and Hank -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CABx2%3DD8E4uy3XLGV44vx7CLS4KVefi7L1TSjquWB%3D3VNGCpEqg%40mail.gmail.com.
Re: [go-nuts] Parsing go.mod
Thanks. I saw the same being done by vgo - might be viable. On Monday, September 2, 2019 at 10:52:45 PM UTC-7, kortschak wrote: > > Not really exposed, but there is code you could copy. > > https://golang.org/pkg/cmd/go/internal/modfile/#Parse > > On Mon, 2019-09-02 at 22:44 -0700, James Pettyjohn wrote: > > Hi, > > > > This might be a bad idea but I'm trying to parse the go.mod file for > > data > > as part of my build process - if at all possible I'd like to avoid > > duplicating the data that is already there in another file. > > > > Is there an exposed package that can be used for this? > > > > - J > > > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/7a06f505-187e-473f-b748-a8bf7f114bf6%40googlegroups.com.
Re: [go-nuts] Parsing go.mod
Sorry I left out the details. So far it's two specific properties I need for instructions in my build process: 1) The full name of the package 2) The version of the protobuf dependency for locking the right version protoc-gen-go before running protoc (that has been asked quite a few times, total hack, but works). Best, James On Monday, September 2, 2019 at 10:58:53 PM UTC-7, Kurtis Rader wrote: > > On Mon, Sep 2, 2019 at 10:44 PM James Pettyjohn > wrote: > >> This might be a bad idea but I'm trying to parse the go.mod file for data >> as part of my build process - if at all possible I'd like to avoid >> duplicating the data that is already there in another file. >> > > In this type of situation you should explain why you need to parse a > go.mod file. Especially since you seem to be asking something not already > asked a thousand times. It is possible, perhaps likely, the reason you want > to do this can be solved some other way. > > -- > Kurtis Rader > Caretaker of the exceptional canines Junior and Hank > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/8b716cac-0eb6-4e95-bdde-12ee832e06a4%40googlegroups.com.
Re: [go-nuts] Parsing go.mod
Also note that you can run: go mod edit -json and get JSON output. go help mod edit will given you the types you can then use to unmarshal the JSON. Failing that, the code that Dan referenced has been factored out into: https://godoc.org/github.com/rogpeppe/go-internal/modfile On Tue, 3 Sep 2019 at 08:21, James Pettyjohn wrote: > > Thanks. I saw the same being done by vgo - might be viable. > > On Monday, September 2, 2019 at 10:52:45 PM UTC-7, kortschak wrote: >> >> Not really exposed, but there is code you could copy. >> >> https://golang.org/pkg/cmd/go/internal/modfile/#Parse >> >> On Mon, 2019-09-02 at 22:44 -0700, James Pettyjohn wrote: >> > Hi, >> > >> > This might be a bad idea but I'm trying to parse the go.mod file for >> > data >> > as part of my build process - if at all possible I'd like to avoid >> > duplicating the data that is already there in another file. >> > >> > Is there an exposed package that can be used for this? >> > >> > - J >> > >> > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/7a06f505-187e-473f-b748-a8bf7f114bf6%40googlegroups.com. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACoUkn5xz0Hjew_RuJHTeah%3DyJVr56sS55ym6rDaFfABBFAOAA%40mail.gmail.com.
Re: [go-nuts] Parsing go.mod
> Sorry I left out the details. So far it's two specific properties I need for > instructions in my build process: > > 1) The full name of the package go list -f {{.Name}} example.com/blah > 2) The version of the protobuf dependency for locking the right version > protoc-gen-go before running protoc (that has been asked quite a few times, > total hack, but works). go list -f {{.Version}} -m example.com/blah Note that if you have a replace directive for example.com/blah then the replace target might have a version. For more detail on either of the above see: go help list > > Best, > James > > On Monday, September 2, 2019 at 10:58:53 PM UTC-7, Kurtis Rader wrote: >> >> On Mon, Sep 2, 2019 at 10:44 PM James Pettyjohn wrote: >>> >>> This might be a bad idea but I'm trying to parse the go.mod file for data >>> as part of my build process - if at all possible I'd like to avoid >>> duplicating the data that is already there in another file. >> >> >> In this type of situation you should explain why you need to parse a go.mod >> file. Especially since you seem to be asking something not already asked a >> thousand times. It is possible, perhaps likely, the reason you want to do >> this can be solved some other way. >> >> -- >> Kurtis Rader >> Caretaker of the exceptional canines Junior and Hank > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/8b716cac-0eb6-4e95-bdde-12ee832e06a4%40googlegroups.com. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACoUkn4MouSb-spFS-NvdYZdC827%2Bx28pXLD0ABd%3D52AHBvfaw%40mail.gmail.com.
Re: [go-nuts] Parsing go.mod
The parsing code will eventually be public, see https://github.com/golang/go/issues/31761 When it is done, you would want golang.org/x/mod/modfile, which will be a (possibly modified) copy of the compiler internal package of the same name. On Tue, Sep 3, 2019 at 3:29 AM Paul Jolly wrote: > > Sorry I left out the details. So far it's two specific properties I need > for instructions in my build process: > > > > 1) The full name of the package > > go list -f {{.Name}} example.com/blah > > > 2) The version of the protobuf dependency for locking the right version > protoc-gen-go before running protoc (that has been asked quite a few times, > total hack, but works). > > go list -f {{.Version}} -m example.com/blah > > Note that if you have a replace directive for example.com/blah then > the replace target might have a version. > > For more detail on either of the above see: > > go help list > > > > > Best, > > James > > > > On Monday, September 2, 2019 at 10:58:53 PM UTC-7, Kurtis Rader wrote: > >> > >> On Mon, Sep 2, 2019 at 10:44 PM James Pettyjohn > wrote: > >>> > >>> This might be a bad idea but I'm trying to parse the go.mod file for > data as part of my build process - if at all possible I'd like to avoid > duplicating the data that is already there in another file. > >> > >> > >> In this type of situation you should explain why you need to parse a > go.mod file. Especially since you seem to be asking something not already > asked a thousand times. It is possible, perhaps likely, the reason you want > to do this can be solved some other way. > >> > >> -- > >> Kurtis Rader > >> Caretaker of the exceptional canines Junior and Hank > > > > -- > > You received this message because you are subscribed to the Google > Groups "golang-nuts" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to golang-nuts+unsubscr...@googlegroups.com. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/8b716cac-0eb6-4e95-bdde-12ee832e06a4%40googlegroups.com > . > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/CACoUkn4MouSb-spFS-NvdYZdC827%2Bx28pXLD0ABd%3D52AHBvfaw%40mail.gmail.com > . > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAA%3DsxTge8ro7tFZvGxyOShKQ5278ky30z7ySyr53eeFGG1eqKA%40mail.gmail.com.
Re: [go-nuts] Parsing go.mod
That's good news, gives me some confidence that the tooling will keep working after 1.14. On Tuesday, September 3, 2019 at 6:43:15 PM UTC-7, Ian Cottrell wrote: > > The parsing code will eventually be public, see > https://github.com/golang/go/issues/31761 > When it is done, you would want golang.org/x/mod/modfile, which will be a > (possibly modified) copy of the compiler internal package of the same name. > > > On Tue, Sep 3, 2019 at 3:29 AM Paul Jolly > > wrote: > >> > Sorry I left out the details. So far it's two specific properties I >> need for instructions in my build process: >> > >> > 1) The full name of the package >> >> go list -f {{.Name}} example.com/blah >> >> > 2) The version of the protobuf dependency for locking the right version >> protoc-gen-go before running protoc (that has been asked quite a few times, >> total hack, but works). >> >> go list -f {{.Version}} -m example.com/blah >> >> Note that if you have a replace directive for example.com/blah then >> the replace target might have a version. >> >> For more detail on either of the above see: >> >> go help list >> >> > >> > Best, >> > James >> > >> > On Monday, September 2, 2019 at 10:58:53 PM UTC-7, Kurtis Rader wrote: >> >> >> >> On Mon, Sep 2, 2019 at 10:44 PM James Pettyjohn >> wrote: >> >>> >> >>> This might be a bad idea but I'm trying to parse the go.mod file for >> data as part of my build process - if at all possible I'd like to avoid >> duplicating the data that is already there in another file. >> >> >> >> >> >> In this type of situation you should explain why you need to parse a >> go.mod file. Especially since you seem to be asking something not already >> asked a thousand times. It is possible, perhaps likely, the reason you want >> to do this can be solved some other way. >> >> >> >> -- >> >> Kurtis Rader >> >> Caretaker of the exceptional canines Junior and Hank >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups "golang-nuts" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> an email to golan...@googlegroups.com . >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/golang-nuts/8b716cac-0eb6-4e95-bdde-12ee832e06a4%40googlegroups.com >> . >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golan...@googlegroups.com . >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/golang-nuts/CACoUkn4MouSb-spFS-NvdYZdC827%2Bx28pXLD0ABd%3D52AHBvfaw%40mail.gmail.com >> . >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/23c433db-83b1-4fb9-b8c6-99631b0f3952%40googlegroups.com.
Re: [go-nuts] Parsing go.mod
Thanks a lot for the tips. This repo is working out and should hold me over, as Ian mentioned, until golang.org/x/mod/modfile is out. On Tuesday, September 3, 2019 at 12:26:28 AM UTC-7, Paul Jolly wrote: > > Also note that you can run: > > go mod edit -json > > and get JSON output. > > go help mod edit > > will given you the types you can then use to unmarshal the JSON. > > Failing that, the code that Dan referenced has been factored out into: > > https://godoc.org/github.com/rogpeppe/go-internal/modfile > > On Tue, 3 Sep 2019 at 08:21, James Pettyjohn > wrote: > > > > Thanks. I saw the same being done by vgo - might be viable. > > > > On Monday, September 2, 2019 at 10:52:45 PM UTC-7, kortschak wrote: > >> > >> Not really exposed, but there is code you could copy. > >> > >> https://golang.org/pkg/cmd/go/internal/modfile/#Parse > >> > >> On Mon, 2019-09-02 at 22:44 -0700, James Pettyjohn wrote: > >> > Hi, > >> > > >> > This might be a bad idea but I'm trying to parse the go.mod file for > >> > data > >> > as part of my build process - if at all possible I'd like to avoid > >> > duplicating the data that is already there in another file. > >> > > >> > Is there an exposed package that can be used for this? > >> > > >> > - J > >> > > >> > > -- > > You received this message because you are subscribed to the Google > Groups "golang-nuts" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to golan...@googlegroups.com . > > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/7a06f505-187e-473f-b748-a8bf7f114bf6%40googlegroups.com. > > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/2a4fd111-ffaf-4c9c-a427-f10c04af6f35%40googlegroups.com.