| 1 |
# The Go Cloud Development Kit (Go CDK) |
| 2 |
|
| 3 |
_Write once, run on any cloud ☁️_ |
| 4 |
|
| 5 |
[](https://github.com/google/go-cloud/actions) |
| 6 |
[](https://goreportcard.com/report/github.com/google/go-cloud) |
| 7 |
[][PkgGoDev] |
| 8 |
[](https://codecov.io/gh/google/go-cloud) |
| 9 |
 |
| 10 |
[](https://opensource.org/licenses/Apache-2.0) |
| 11 |
|
| 12 |
<p align="center"> |
| 13 |
<img width="509" height="276" src="internal/website/static/go-cdk-logo-gopherblue.png" alt=""> |
| 14 |
</p> |
| 15 |
|
| 16 |
The Go Cloud Development Kit (Go CDK) allows Go application developers to |
| 17 |
seamlessly deploy cloud applications on any combination of cloud providers. It |
| 18 |
does this by providing stable, idiomatic interfaces for common uses like storage |
| 19 |
and databases. Think `database/sql` for cloud products. |
| 20 |
|
| 21 |
Imagine writing this to read from blob storage (like Google Cloud Storage or |
| 22 |
S3): |
| 23 |
|
| 24 |
```go |
| 25 |
ctx := context.Background() |
| 26 |
bucket, err := blob.OpenBucket(ctx, "s3://my-bucket") |
| 27 |
if err != nil { |
| 28 |
return err |
| 29 |
} |
| 30 |
defer bucket.Close() |
| 31 |
blobReader, err := bucket.NewReader(ctx, "my-blob", nil) |
| 32 |
if err != nil { |
| 33 |
return err |
| 34 |
} |
| 35 |
``` |
| 36 |
|
| 37 |
and being able to run that code on any cloud you want, avoiding all the ceremony |
| 38 |
of cloud-specific authorization, tracing, SDKs and all the other code required |
| 39 |
to make an application portable across cloud platforms. |
| 40 |
|
| 41 |
The project works well with a code generator called |
| 42 |
[Wire](https://github.com/google/wire/blob/master/README.md). It creates |
| 43 |
human-readable code that only imports the cloud SDKs for services you use. This |
| 44 |
allows the Go CDK to grow to support any number of cloud services, without |
| 45 |
increasing compile times or binary sizes, and avoiding any side effects from |
| 46 |
`init()` functions. |
| 47 |
|
| 48 |
You can learn more about the project from our [announcement blog post][], or our |
| 49 |
talk at Next 2018: |
| 50 |
|
| 51 |
[][video] |
| 52 |
|
| 53 |
[announcement blog post]: https://blog.golang.org/go-cloud |
| 54 |
[PkgGoDev]: https://pkg.go.dev/mod/gocloud.dev |
| 55 |
[travis]: https://travis-ci.com/google/go-cloud |
| 56 |
[video]: https://www.youtube.com/watch?v=_2ZwhvIkgek |
| 57 |
|
| 58 |
## Installation |
| 59 |
|
| 60 |
```shell |
| 61 |
# First "cd" into your project directory if you have one to ensure "go get" uses |
| 62 |
# Go modules (or not) appropriately. See "go help modules" for more info. |
| 63 |
go get gocloud.dev |
| 64 |
``` |
| 65 |
|
| 66 |
The Go CDK builds at the latest stable release of Go. Previous Go versions may |
| 67 |
compile but are not supported. |
| 68 |
|
| 69 |
## Documentation |
| 70 |
|
| 71 |
Documentation for the project lives primarily on https://gocloud.dev/, including |
| 72 |
[tutorials][]. |
| 73 |
|
| 74 |
You can also browse Go package reference on [pkg.go.dev][PkgGoDev]. |
| 75 |
|
| 76 |
[tutorials]: https://gocloud.dev/tutorials/ |
| 77 |
|
| 78 |
## Project status |
| 79 |
|
| 80 |
The APIs are still in alpha, but we think they are production-ready and are |
| 81 |
actively looking for feedback from early adopters. If you have comments or |
| 82 |
questions please open an issue. |
| 83 |
|
| 84 |
At this time we prefer to focus on maintaining the existing APIs and drivers, |
| 85 |
and are unlikely to accept new ones into the `go-cloud` repository. The modular |
| 86 |
nature of the Go CDK makes it simple to host new APIs and drivers for existing |
| 87 |
APIs externally, in separate repositories. |
| 88 |
|
| 89 |
If you have a new API or driver that you believe are important and mature enough |
| 90 |
to be included, feel free to open an issue to discuss this; our default will |
| 91 |
likely be to suggest starting in a separate repository. We'll also be happy |
| 92 |
to maintain a list of such external APIs and drivers in this README. |
| 93 |
|
| 94 |
## Current features |
| 95 |
|
| 96 |
The Go CDK provides generic APIs for: |
| 97 |
|
| 98 |
* Unstructured binary (blob) storage |
| 99 |
* Publish/Subscribe (pubsub) |
| 100 |
* Variables that change at runtime (runtimevar) |
| 101 |
* Connecting to MySQL (including MariaDB) and PostgreSQL databases (mysql, postgres) |
| 102 |
* Server startup and diagnostics: request logging, tracing, and health |
| 103 |
checking (server) |
| 104 |
|
| 105 |
## Contributing |
| 106 |
|
| 107 |
Thank you for your interest in contributing to the Go Cloud Development |
| 108 |
Kit! :heart: |
| 109 |
|
| 110 |
Everyone is welcome to contribute, whether it's in the form of code, |
| 111 |
documentation, bug reports, feature requests, or anything else. We encourage you |
| 112 |
to experiment with the Go CDK and make contributions to help evolve it to meet |
| 113 |
your needs! |
| 114 |
|
| 115 |
The GitHub repository at [google/go-cloud][go-cloud] contains some driver |
| 116 |
implementations for each portable API. We intend to include |
| 117 |
[Google Cloud Platform][gcp], [Amazon Web Services][aws], and [Azure][azure] |
| 118 |
implementations, as well as prominent open source services and at least one |
| 119 |
implementation suitable for use in local testing. Unfortunately, we cannot |
| 120 |
support every service directly from the project; however, we encourage |
| 121 |
contributions in separate repositories. |
| 122 |
|
| 123 |
If you create a repository that implements the Go CDK interfaces for other |
| 124 |
services, let us know! We would be happy to link to it here and give you a |
| 125 |
heads-up before making any breaking changes. |
| 126 |
|
| 127 |
See [the contributing guide](./CONTRIBUTING.md) for more details. |
| 128 |
|
| 129 |
[go-cloud]: https://github.com/google/go-cloud |
| 130 |
[gcp]: http://cloud.google.com |
| 131 |
[aws]: http://aws.amazon.com |
| 132 |
[azure]: https://azure.microsoft.com/ |
| 133 |
|
| 134 |
## Community |
| 135 |
|
| 136 |
This project is covered by the Go [Code of Conduct][]. |
| 137 |
|
| 138 |
[Code of Conduct]: ./CODE_OF_CONDUCT.md |
| 139 |
|
| 140 |
## Legal disclaimer |
| 141 |
|
| 142 |
The Go CDK is open-source and released under an [Apache 2.0 |
| 143 |
License](https://github.com/google/go-cloud/blob/master/LICENSE). Copyright © |
| 144 |
2018–2019 The Go Cloud Development Kit Authors. |
| 145 |
|
| 146 |
If you are looking for the website of GoCloud Systems, which is unrelated to the |
| 147 |
Go CDK, visit https://gocloud.systems. |