Google Cloud Training in Chennai | Cloud Functions

google cloud training in chennai

Get Go-ing with Cloud Functions: Go 1.11 is now a supported language

Since releasing Node.js and Python as supported languages for Google Cloud Functions this summer, our team has been hard at work. Today, we’re excited to announce support for Go on Cloud Functions. google cloud training in chennai

Now in beta, the runtime uses the latest version, Go 1.11, which includes new language features like modules for integrating third-party dependencies into your code. Starting today, you can write Go functions that scale dynamically in response to load and integrate seamlessly with Google Cloud events.

Two ways to Go

Let’s take a look at the two types of functions that you can use with Cloud Functions: HTTP functions and background functions. google cloud training in chennai

HTTP functions are what their name suggests: functions that are invoked by HTTP requests. They follow the http.HandlerFunc type from the standard library. For example, an HTTP function that returns a caller’s IP address might look like this:

// function.go
package function

import "net/http"

func F(w http.ResponseWriter, r *http.Request) {
        w.Header().Set("Content-Type", "text/plain; charset=utf-8")
        w.Write([]byte(r.Header.Get("X-Forwarded-For")))
}

HTTP functions can be reached without an additional API gateway layer—Cloud Functions gives you an HTTPS URL. After the function is deployed, you can invoke the function by entering the URL into your browser.

In contrast, background functions are triggered in response to an event. Your function might, for example, run every time the contents of a Cloud Storage bucket change. Let’s look at an example function that triggers when a file is added to a Cloud Storage bucket:

// function.go

// Package function includes an example of processing a GCS event.
package function

import (
        "context"
        "log"
)

// GCSEvent holds event data from a Google Cloud Storage Event.
type GCSEvent struct {
        Bucket      string `json:"bucket"`
        Name        string `json:"name"`
}

func F(ctx context.Context, e GCSEvent) error {
        log.Printf("Processing file: %s", e.Name)
        return nil
}

When you deploy your function, you also indicate a specific Cloud Storage bucket. Every time a new file appears in that bucket, your function runs and logs the file’s name. google cloud training in chennai

These are just two small examples of what’s possible with Cloud Functions and Go. The runtime supports a rich ecosystem of Go packages via Go modules. For example, to use the Cloud Translation client library in your function, create a `go.mod` file by running the following commands:

export GO111MODULE=on
go mod init example.com/myfunctions
go get cloud.google.com/go/translate

When you deploy your function, Cloud Functions fetches and installs the dependencies listed in your `go.mod` file.

Using Cloud Functions, you can build serverless application backends, real-time data processing pipelines, chatbots, and video or image analysis tools, just to name a few. Now, you can also use the familiar building blocks of Go to build out your Cloud Functions.

Articles_Source : Cloud_Google

You Must Be like:

1.Game_of_the_year

2.Ulta and DSW

3.Snowflake

Leave a Reply


Working Hours

  • Monday9am - 6pm
  • Tuesday9am - 6pm
  • Wednesday9am - 6pm
  • Thursday9am - 6pm
  • Friday9am - 6pm
  • SaturdayClosed
  • SundayClosed
Latest Posts

Big Data training Academy in chennai
data science course in chennai
Wanna attend a demo class?

We are glad that you preferred to schedule a demo class. Please fill our short form and one of our friendly team members will contact you back.


[recaptcha]

X
Demo Class