Google Makes it Easier to Create Go Applications on Google Cloud
source link: https://www.infoq.com/news/2023/08/google-cloud-gonew-templates/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Google Makes it Easier to Create Go Applications on Google Cloud
Aug 09, 2023 1 min read
Google released four templates developers can use to bootstrap Go applications using gonew
, an experimental tool aimed at instantiating Go projects.
The new templates include httpfn
, which creates a basic HTTP handler using Cloud Function; pubsubfn
, a Cloud Function that is subscribed to a PubSub topic handling a Cloud Event; [microservice
(https://github.com/GoogleCloudPlatform/go-templates/tree/main/run/microservice)], a Cloud Run HTTP server meant to be deployed to a serverless runtime; and taskhandler
, which is a basic app handling tasks using App Engine.
Using a template simplifies the process of writing a Go service and deploying it to Google Cloud. Each template includes a basic Go program implementing the required functionality and a dependency file. More complex services may include additional configuration files, such as yaml files to configure Cloud services.
For example, in the case of a simple HTTP handler, if you use the httpfs
gonew
template, once you have gonew
installed, the whole process comes down to two steps: downloading the project template and deploying it.
gonew github.com/GoogleCloudPlatform/go-templates/functions/httpfn your.domain/httpfn
gcloud functions deploy hello-http \
--gen2 \
--runtime=go120 \
--region=us-central1 \
--source=. \
--entry-point=HelloHTTP \
--trigger-http \
--allow-unauthenticated
Compare this with the steps required to write a simple Cloud Function using the Go runtime to accomplish the same goal. Those include creating a Google Cloud project using gcloud
CLI, implementing the required functionality writing a simple Go program, then deploying it. The benefits are even more evident if you look at the steps required to create a simple task handler using Google App Engine.
As mentioned, the Go templates leverage the recently introduced gonew
tool, which aims to simplify the task of bootstrapping a Go project.
For a long time now, we have heard from Go developers that getting started is often the hardest part. New developers coming from other languages expect guidance on a default project layout, experienced developers working on teams expect consistency in their projects’ dependencies.
Templates for gonew
, which are packaged as Go modules, can be written by anyone. The initial release of the tool is intentionally minimal and aimed to gather feedback from the developer base.
About the Author
Sergio De Simone
Sergio De Simone is a software engineer. Sergio has been working as a software engineer for over fifteen years across a range of different projects and companies, including such different work environments as Siemens, HP, and small startups. For the last few years, his focus has been on development for mobile platforms and related technologies. He is currently working for BigML, Inc., where he leads iOS and OS X development.
Show moreRecommend
-
2
Andrew Ng’s Landing AI makes it easier to create computer vision apps with Visual Prompting
-
8
SEO Google makes it easier to remove images of kids from the search results This may come in handy if you work in online reputati...
-
4
(Image credit: Derrek Lee / Android Central)
-
6
Google Docs logo (Image credit: Jay Bonggolto / Android Central)
-
2
April 21, 2022
-
6
Google makes it easier to reject tracking cookies in Europe after fines from watchdogs A step in the right direction By Tudor Cibean...
-
5
Google TV’s new Favorite Channels makes it far easier to find something to watch By James Peckham...
-
12
Google Search makes finding at-home COVID-19 tests in stores a whole lot easier By Will Sattelberg Published 2 hours ag...
-
11
Google makes it easier for your stuff to sync between Android phones and ChromebooksKris Holt·Contributing Report...
-
4
A new version of the Switch to Android app is live
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK