keybase / go-keychain

Golang keychain package for iOS and macOS
MIT License
573 stars 120 forks source link

secretservice subpackage not documented or exported #70

Closed ringerc closed 2 years ago

ringerc commented 3 years ago

There's support for the D-Bus based secretservice in the secretservice/ subdir and secretservice package.

But as far as I can tell (admittedly as an absolute golang newbie) it doesn't seem to be usable from outside the tests that are the secretservice package itself. Should the secretservice tests not use a different package and import secretservice ?

Using

go init secretserviceexample
go get github.com/keybase/go-keychain

then secretserviceexample.go:

package secretserviceexample
import (
    "github.com/keybase/go-keychain"
)
func main() {
    srv, err := keychain.NewService()
}

this fails with

$ go build
./secretserviceexample.go:8:17: undefined: keychain.NewService

There doesn't appear to be anything in the keychain package to adapt the secretservice API to the Keychain API such that the main keychain package funcs can be used transparently-ish on Linux. Maybe that was intended but unfinished?

ringerc commented 3 years ago

To help others as ignorant of golang as me, you have to import the subpackage from the module explicitly:

$ go get github.com/keybase/go-keychain/secretservice

then

package secretserviceexample

import (
    "github.com/keybase/go-keychain/secretservice"
)

func main() {
    srv, err := secretservice.NewService()
    /* .... */
}

The rest of the API is moderately readable in secretservice/secretservice.go and the freedesktop spec.

I'll try to find time to add an example to the README soon.

benma commented 10 months ago

Please add the example - I almost thought there is no Linux support after all when checking the README and doing a quick scan through the Go files in the root.