In this article, we are going to look at some of the basic APIs of the http package to create and initialize HTTPS servers in Go
httppackage to create and initialize HTTPS servers in Go.
In the “Simple Hello World Server” lesson, we learned about
net/http package, how to create routes and how
[ServeMux](https://golang.org/pkg/net/http/#ServeMux) works. In the “Running multiple HTTP servers” lesson, we learned about
[Server](https://golang.org/pkg/net/http/#Server) structure and how to run multiple HTTP servers concurrently.
In this lesson, we are going to create an HTTPS server using both Go’s standard server configuration and custom configuration (using _
[_Server_](https://golang.org/pkg/net/http/#Server) structure_). But before this, we need to know what HTTPS really is?
HTTPS is a big topic of discussion in itself. Hence while writing this lesson, I published an article just on “How HTTPS works?”. I advise you to read this lesson first before continuing this article. In this article, I’ve also described the encryption paradigm and SSL certificates generation process.
If we recall the simplest HTTP server example from previous lessons, we only need
http.``[ListenAndServe](https://golang.org/pkg/net/http/#ListenAndServe) function to start an HTTP server and
http.``[HandleFunc](https://golang.org/pkg/net/http/#HandleFunc) to register a response handler for a particular endpoint.
In the example above, when we run the command
go run server.go , it will start an HTTP server on port
9000. By visiting
http://localhost:9000 URL in a browser, you will be able to see a
Hello World! message on the screen.
As we know, the
nil argument to
ListenAndServe() call invokes Go to use the
[DefaultServeMux](https://golang.org/pkg/net/http/#DefaultServeMux) response multiplexer, which is the default instance of
ServeMux structure provided globally by the Go. The
HandleFunc() call adds a response handler for a specific route on the multiplexer instance.
http.ListenAndServe() call uses the Go’s standard HTTP server configuration, however, in the previous lesson, how we can customize a server using
[Server](https://golang.org/pkg/net/http/#Server) structure type.
To start an HTTPS server, all we need do is to call
ServerAndListenTLS method with some configuration. Just like
ServeAndListen method, this method is available on both the
http package and the
http.``[ServeAndListenTLS](https://golang.org/pkg/net/http/#ListenAndServeTLS) method uses the Go’s standard server implementation, however, both
[Server](https://golang.org/pkg/net/http/#Server) instance and
Server.``[ServeAndListenTLS](https://golang.org/pkg/net/http/#Server.ListenAndServeTLS) method can be configured for our needs.
In this article, we are going to see the four important collection types built into the language. we start with humble Arrays, Maps, Slices
Welcome to this course on Go Programming Language Tutorial. Go is an open source programming language which was originally developed by Google. In this Go Tutorial we will Learn Go from the Basics with Code Examples. Go is a statically-typed language. Go has a syntax similar to C. Go has built-in concurrency.
Learn the Go programming language (Golang) in this step-by-step tutorial course for beginners. Go is an open source programming language designed at Google that makes it easy to build simple, reliable, and efficient software.
Golang array is a fixed-size collection of items of the same type. The items of an array are stored sequentially and can be accessed using their index.
Go is praised by everyone for achieving extremely high concurrent performance, but Why? In this Golang (Go) tutorial, I’ll introduce how the Go program to achieve extremely high concurrent performance, and its internal scheduler implementation architecture (G-P-M model). I’ll also explain how Go can make full use of computing resources, and how the Go scheduler deals with threads step by step