Get ShaXXX of a GO Package - go

I Need to get the Sha512 or similar from a Golang package for SBOM purposes.
For example, the hash for package
https://pkg.go.dev/encoding/json
I can't found any information or api to get it. If possible I need it without download the source code.

I think you are looking for sum.golang.org which is
an auditable checksum database which will be used by the go command to
authenticate modules.
you can read more on how it works on this post from go blog

Related

how to fetch file from remote repository on bitbucket using go language

I have latest file which is on remote bitbucket repo.
I need use Go language program in that I need to fetch above file from "go get" is this possible ?
How to write code in go language to do this.
You don't even need to write any go code for this, just do:
go get <bitbucket repo URL>
Make sure that the URL is public so go get can work. Bear in mind that to use this package, you need to import in in your main.go program.

Conflicting type in golang compilation [duplicate]

I'm trying to use this Golang Yelp API package. In some of its structs, it uses types defined in guregu's null package.
I want to declare a struct defined in the Yelp API package, where some of its fields have null.Float as a value (i.e. this struct, which im trying to use). So in my program, I import both the Yelp API package and guregu's null package and try to declare the struct, with ip.Lat and ip.Lat being float64s. (null.FloatFrom definition):
33 locationOptions := yelp.LocationOptions{
34 ip.Zip,
35 &yelp.CoordinateOptions{
36 Latitude: null.FloatFrom(ip.Lat),
37 Longitude: null.FloatFrom(ip.Lon),
38 },
39 }
But when I run the program, it tells me:
./cli.go:36: cannot use "github.com/guregu/null".FloatFrom(ip.Lat) (type
"github.com/guregu/null".Float) as type "github.com/JustinBeckwith/go-
yelp/yelp/vendor/github.com/guregu/null".Float in field value
I tried 2 things:
1) I did not import the null package, which caused Go to complain about null being undefined. 2) I also tried importing the vendored package directly, which caused Go to tell me use of vendored package not allowed.
Any Ideas on how to fix this?
The solution here seems to be that the library I'm trying to use needs to be reworked to prevent this kind of thing from happening.
The two possible ways to change the library seem to be
1) not vendor at all - this works if the dependency does not need to be a specific version.
2) vendored, but do not expose the vendored library to the public. Create some wrapper functions in the library so that people can create the types indirectly.
See this discussion about vendoring on reddit for more ideas/reasons why.
I had the same issue. As a work around, I deleted the associated package's vendor folder and moved their content to my $GOPATH folder.
Source of answer: promql Go import problem: use of vendored package not allowed
Just had a similar issue. Putting both libraries in /vendor resolved. Using govendor get xxxx
Had a similar issue while using Godep and I resolved by deleting /vendor and re-running godep save ./... - Hope it helps.

Laravel mailChimp package error

I try to use the package https://github.com/BlueBayTravel/Mailchimp as in examples but i got an error:
ErrorException in Mailchimp.php line 64:
Undefined property: BlueBayTravel\Mailchimp\Facades\Mailchimp::$users
when i try to use: Mailchimp::users(), while i can get a connection via Mailchimp::getDefaultConnection(); mean the package is completely red, what u guess the problem with me here ?
I saw that you already opened an issue in the package repo.
If you are using Laravel, and you want to use an existing integration with Mailchimp, I would recommend you to give a try to the spatie/laravel-newsletter package. It's the most complete package I've found for the integration Laravel + Mailchimp, and it uses the drewm/mailchimp-api API wrapper (which IMO, is the best php wrapper for Mailchimp). You can find some examples at Freek's blog or at the README file of the project. And if you do not find what you need, you can go to a lower level using the drewm wrapper: $api = Newsletter::getApi();
If this is not what you are looking for, you can always create your own service in Laravel, adapted to your needs and requierements ;)

Dredd can't find my API documentation, how do i tell it where it is if it's not on my local drive (it's on apiary.io server)

I am using the Dredd tool to test my API (which resides on apiary.io).
Question
I would like to provide dredd with a path to my documentation (it even asks for it), however my API doc is on apiary.io but i don't know the exact url that points to it. What would be the correct way to provide dredd with the API path?
What did work (but not what i'm looking for)
Note: I tried downloading the api to my local drive and providing dredd with a local path to the file (yml or apib) which works fine (yay!), but i would like to avoid keeping a local copy and simply providing dredd with the location of my real API doc which is being maintained on the apiary server.
How do I do this (without first fetching the file to local drive)?
Attempts to solve this that failed
I also read (and tried) on the following topics, they may be relevant but i wasn't successful in resolving the issue
- Using authentication token as environment variable
- Providing the domain provided by apiary.io//settings to dredd
- Providing the in the dredd command
all of these attempts still produces the same result, Dredd has no idea where to find the API document unless i provide a path in my local computer to the file (which i have to download or create manually on my computer first).
Any help is appreciated, Thanks!
If I understand it correctly, you would like to use dredd and feed it using the API description document residing on Apiar.io platform, right?
If so, you should be able to do that simply calling the init command with the right options:
dredd init -r apiary -j apiaryApiKey:privateToken -j apiaryApiName:sasdasdasd
You can find the private token going into the Test section of the target API (you'll find the button on the application header).
Let me know if this solves the problem for you - I'll make sure to propagate this and document it accordingly on our help page
P.S: You can also use your own reporter - in that case, simply omit -r apiary when writing the command line parameters.
You can feed Dredd not only with a path to file on your disk, but also with an URL.
If your API in Apiary is public, the API description document (in this case API Blueprint) should have a public URL. For example, if you go to http://docs.apiblueprintapi.apiary.io/, you can see on the left there is a Download link. Unfortunately, the link is visible only for users who do not have access to the editor of the API, so you can’t see the link if you’re owner of the API. Try to log out from Apiary and the link should appear:
Then you can feed Dredd with the link:
$ dredd 'http://docs.apiblueprintapi.apiary.io/api-description-document' 'http://example.com:8080/api'
I agree this isn’t very intuitive and since you’re not the first one to come up with this, I think we’ll think of some ways how to make it easier.
If your API isn't public then unfortunately there's no way to get the URL as of now. However, you can either use GitHub Sync or Apiary CLI to get the file on your disk in an automated manner.

Using PGP in golang

I'm trying to encrypt a string using the openPGP package in golang, but so far I haven't been successful.
Nothing that I've tried so far has worked, so I'm looking for any sort of suggestions or fixes.
The only requirements I have is that it should take the public/private key and the string to decrypt as a string, not files.
I tried to use the examples from this post: http://julianyap.com/2014/07/04/gnu-privacy-guard-gpg-examples-using-golang.html
Specifically this example: https://gist.github.com/jyap808/8324818
But when I run that out of the box it saids the following when trying to read the key
openpgp: invalid argument: no armored data found
And I've found no other good example/working package.
I'm starting to run out of options, as I originally tried to do this in PHP, but failed horribly there too. Would be great if anyone could offer some suggestions!
Thanks in advance
Here's a PGP package for Golang that abstracts away most of the complications and is pretty easy to use:
https://github.com/jchavannes/go-pgp
Checkout the test file for an example:
https://github.com/jchavannes/go-pgp/blob/master/pgp/encrypt_test.go

Resources