1585041780
Go is a procedural programming language. It was developed in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson at Google but launched in 2009 as an open-source programming language. Programs are assembled by using packages, for efficient management of dependencies. This language also supports environment adopting patterns alike to dynamic languages. For eg., type inference (y := 0 is a valid declaration of a variable y of type float).
There are various online IDEs such as The Go Playground, repl.it, etc. which can be used to run Go programs without installing.
For installing Go in own PCs or Laptop we need of following two software: Text editor and Compiler
Text Editor: Text editor gives you a platform where you write your source code. Following are the list of text editors:
Finding a Go Compiler: Go distribution comes as a binary installable for FreeBSD (release 8 and above), Linux, Mac OS X (Snow Leopard and above), and Windows operating systems with 32-bit (386) and 64-bit (amd64) x86 processor architectures.
For more instructions about installing. Please visit For installing GO distribution
Note: Extension of source code file of go language must be .go
Writing first program in Go:
package main
import "fmt"
func main() {
// prints Morioh
fmt.Println("Hello, Morioh")
}
Output:
Hello, Morioh
Explanation of the syntax of Go program:
Single Line Comment:
Syntax:
// single line comment
Multi line Comment:
Syntax:
/* multiline comment */
Following is another example:
package main
import "fmt"
func main() {
fmt.Println("1 + 1 =", 1 + 1)
}
Output:
1 + 1 = 2
Explanation of the above program:
In this above program, the same package line, the same import line, the same function declaration and uses the same Println function as we have used in 1st GO program. This time instead of printing the string “Hello, geeksforgeeks” we print the string 1 + 1 = followed by the result of the expression 1 + 1. This expression is made up of three parts: the numeric literal 1 (which is of type int), the + operator (which represents addition) and another numeric literal 1.
Because Go language is an effort to combine the ease of programming of an interpreted, dynamically typed language with the efficiency and safety of a statically typed, compiled language. It also aims to be modern, with support for networked and multicore computing.
We have observed that in a decade, the hardware and processing configuration is changing at a very slow rate. In 2004, P4 was having the clock speed of 3.0 GHz and now in 2018, Macbook pro has the clock speed of Approx (2.3Ghz v 2.66Ghz). To speed up, the functionality we use more processors, but using more processor the cost also increases. And due to this we use limited processors and using limited processor we have a heavy prog. language whose threading takes more memory and slows down the performance of our system, Hence to overcome such problem Golang has been designed in such a way that instead of using threading it uses Goroutine, which is similar to threading but consumes very less memory.
Like threading consumes 1MB whereas Goroutine consumes 2KB of memory, hence at the same time, we can have millions of goroutine triggered.
So the above-discussed point makes golang a strong language that handles concurrency like C++ and Java.
#go #golang #webdev
1594369800
SQL stands for Structured Query Language. SQL is a scripting language expected to store, control, and inquiry information put away in social databases. The main manifestation of SQL showed up in 1974, when a gathering in IBM built up the principal model of a social database. The primary business social database was discharged by Relational Software later turning out to be Oracle.
Models for SQL exist. In any case, the SQL that can be utilized on every last one of the major RDBMS today is in various flavors. This is because of two reasons:
1. The SQL order standard is genuinely intricate, and it isn’t handy to actualize the whole standard.
2. Every database seller needs an approach to separate its item from others.
Right now, contrasts are noted where fitting.
#programming books #beginning sql pdf #commands sql #download free sql full book pdf #introduction to sql pdf #introduction to sql ppt #introduction to sql #practical sql pdf #sql commands pdf with examples free download #sql commands #sql free bool download #sql guide #sql language #sql pdf #sql ppt #sql programming language #sql tutorial for beginners #sql tutorial pdf #sql #structured query language pdf #structured query language ppt #structured query language
1596793260
http
package to create and initialize HTTPS servers in Go.(source: unsplash.com)
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.
(https://play.golang.org/p/t3sOenOYAzS)
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.
The 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 Server
structure.
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.
#go-programming-language #go #golang-tutorial #go-programming #golang
1589642959
We have already seen how to create and work with variables, pointers, and Constants. In this article, we are going to see the four important collection types built into the language.
We start with humble Arrays, from there we move on to Slice, an evolved version of Array. From Slice, we talk about the map a key-value pair collection. Let’s start with Arrays here.
#golang-tutorial #golang #go-programming #go-programming-language #programming
1599854400
Go announced Go 1.15 version on 11 Aug 2020. Highlighted updates and features include Substantial improvements to the Go linker, Improved allocation for small objects at high core counts, X.509 CommonName deprecation, GOPROXY supports skipping proxies that return errors, New embedded tzdata package, Several Core Library improvements and more.
As Go promise for maintaining backward compatibility. After upgrading to the latest Go 1.15 version, almost all existing Golang applications or programs continue to compile and run as older Golang version.
#go #golang #go 1.15 #go features #go improvement #go package #go new features
1633663722
Go, also known as Golang, is an open-source, compiled, and statically typed programming language designed by Google. It is built to be simple, high-performing, readable, and efficient.
In this article, you'll learn:
You might hear the language called both Go and Golang, which might be confusing. I once thought they were names for different languages. But Golang is just another name for Go – and Go remains the official name.
Golang came from the domain name of the Go official website, golang.org. Which is actually really helpful, because “Golang” is much more searchable than "Go" on Google. So it makes life a little easier for those who might be looking for information on the programming language.
The Go programming language was borne because things were getting much more complex in the codebases within Google.
It was designed by Robert Griesemer, Rob Pike, and Ken Thompson, who all reportedly have a shared dislike for C++.
Go was announced to the public in 2009, and it was made open source in 2012 when its first version, 1.0, was released.
Go quickly rose in popularity and became many developers' first choice due to its simplicity, readability, efficiency, and concurrent nature. Concurrent means that it can run multiple tasks at the same time.
Go is used for server-side (backend) programming, game development, cloud-based programming, and even Data Science. It is also popular for making command-line tools.
Today, many tech giants use Go like Google, Netflix, Twitch, Ethereum, Dropbox, Kubernetes, Docker, Heroku, and lots more.
There’s no surprise that the likes of Kubernetes, Docker, and Heroku are using Go because cloud-based programming is one of the main reasons why Go was designed.
Go is one of the simplest programming languages out there. It is easy to pick up especially if you already have knowledge of any other programming language. In my case, I learned the fundamentals of Go in one sitting.
A lot of developers who use Go and are confident in their teaching abilities say that they can get an absolute beginner to build an app with Go in just a few hours.
The simplicity of Go is one of the main reasons it jumped 5 places from the 10th to 5th most loved programming language according to the 2020 StackOverflow Developer Survey.
Go has solid and easy-to-read documentation. You can read the documentation on the official website.
Apart from documentation, Go also has a supportive and active community behind it, so you can always get help when you are stuck.
The hashtag #golang is commonly used on Twitter, so in case you get stuck, you can tweet your question and attached the hashtag to it.
Go is a multipurpose programming language, meaning you can use it for a number of things such as web development, data science, cloud computing, and more.
If you want to have a career in cloud-based programming, you should consider learning Go, because platforms such as Amazon Web Services, Kubernetes, and Google Cloud Platform (GCP) all support Go.
According to the 2020 StackOverflow Developer Survey, Go developers are the third-highest paid after Perl and Scala with a median salary of $74K.
This figure will probably continue to climb, because Go continues to gain more popularity every year and it is in demand. So, if you want to earn more money, you should consider learning Go.
To install Go on your Windows machine, you first have to download Go from the official website. It is available for all popular operating systems. Click on the one that correlates to your OS and install it.
Step 1: Before installing Go, open up your command prompt, type “go” and hit enter. You can open the command prompt by entering “cmd” in the Windows Search bar, and then selecting the first app that shows up.
When you enter “go” and hit enter, you should get a message that says “'go' is not recognized as an internal or external command, operable program or batch file”.
Don’t worry, this is because you have to install Go by double-clicking on the Installer downloaded from the Go website.
Step 2: Double-click on the downloaded installer to install Go. Follow the prompts accordingly and Go will be installed.
Step 3: After installing Go through the installer, head back to the command line and enter “go” again. This time around, you should see several commands available in Go.
Step 4: But you can’t just start programming in Go like that. You have to set up your Go workspace by configuring environment variables.
So, head over to your desktop and create the folder “go-workspace”. You can name it whatever you want. This is the folder where your Go projects will be stored. Only when you set the value of the GOPATH
variable to it. We do this in the next steps.
Step 5: Search for “env” on the windows Searchbar and click on “Edit the system environment variables”.
Step 6: Click on “Environment Variables”.
What you are going to do here is change the value of the GOPATH
variable to the folder you created in Step 4.
Step 7: Make sure “GOPATH” is selected, then click “Edit…”.
Step 8: Click on “Browser Directory”.
Step 9: Select the folder you created in Step 4. That is, “go-workspace”, or whatever you named it.
Click “Ok”.
Click "Ok" again.
And "Ok" again.
That’s it! You can now start programming in Go on your Windows machine.
Step 1: Open up the “go-workspace” folder (or whatever you named it) with VS Code (or your code editor of choice) and create a file named main.go
. You can name the file whatever you want.
Step 2: When you hit enter, you will be prompted to install the Go extension for VS Code. Make sure you install it as it will give your code editor some Golang superpowers such as syntax highlighting and snippet suggestions.
You should also be prompted by VS Code to install some more extensions. Install them all. In my case, I installed everything for my VS Code already and all my extensions are in sync, so I didn’t get those prompts.
Paste in the following code in the main.go file (or whatever you named the file):
package main
import "fmt"
func main() {
fmt.Println("Hello World")
}
What’s the code above doing?
The first line has package main
. “package” is a collection of files and code every Go file has. Think of package
as a containing folder for your Go files and codes.
No matter what you named your file, make sure the “package main” is available on top of your code.
After that fmt
gets brought in. “fmt” is a package from the Go standard library. It is used for formatting strings and printing messages to the command line. It contains methods for doing things in Go.
One of the methods is Println
, meaning “print line”, which we will use to print our “Hello World” text.
Inside the function “main”, the fmt
package was then used to output our “Hello World” text to the console.
To run this code, open up your terminal, type go run main.go
, and hit enter. If you named your file something else, make it go run yourFileName.go
.
In this article, you learned about the Go programming language and why it is a good one to know. You also learned how to install Go on a Windows machine and write your first Hello World program in it.
Go is a powerful programming language that is here to stay. It's clear from the 2020 StackOverflow Developer Survey that developers love Go, and its popularity is rising year by year.
Go is definitely worth your time. Now, go learn some Go.
Original article source at https://www.freecodecamp.org
#go #golang #programming #develope