Structuring Portable Code
The Go CDK’s APIs are intentionally structured to make it easier to separate your application’s core logic from the details of the services it is using.
The documents in this section describe higher level concepts in the Go CDK.
The Go CDK’s APIs are intentionally structured to make it easier to separate your application’s core logic from the details of the services it is using.
In addition to creating portable types via provider-specific constructors
(e.g., creating a *blob.Bucket
using s3blob.OpenBucket
), many portable types
can also be created using a URL. The scheme of the URL specifies the provider,
and each provider implementation has code to convert the URL into the data
needed to call its constructor. For example, calling
blob.OpenBucket("s3blob://my-bucket")
will return a *blob.Bucket
created
using s3blob.OpenBucket
.
It is not feasible or desirable for APIs like blob.Bucket
to encompass the
full functionality of every provider. Rather, we intend to provide a subset
of the most commonly used functionality. There will be cases where a
developer wants to access provider-specific functionality, such as unexposed
APIs or data fields, errors, or options. This can be accomplished using As
functions.