tursodatabase / libsql-client-go

Go client API for libSQL
MIT License
166 stars 23 forks source link

Use a custom connector when an auth token is required #39

Closed CodingDoug closed 10 months ago

CodingDoug commented 1 year ago

Right now, when it's required to connect to sqld with an auth token, the SDK requires that it appear in the URL passed to Open. This isn't the most clean approach, probably only works with the Go SDK, and places additional stress on the formal definition of a libsql URL. Ideally we should find another way to specify the token as a separate item of data, like we do in the other libsql SDKs.

@honzasp points out that the docs for database/sql mentions in the doc for Open that:

Most users will open a database via a driver-specific connection helper function that returns a *DB.

So perhaps we should provide this helper when the developer needs an auth token (but Open alone is fine when doing local development). It looks like OpenDB can take a custom Connector. If we do this, I think auth token support in the URL should become deprecated and eventually removed.

haaawk commented 10 months ago

Fixed by https://github.com/libsql/libsql-client-go/pull/71