
eBook - ePub
Learning Go Programming
Build ScalableNext-Gen Web Application using Golang (English Edition)
- English
- ePUB (mobile friendly)
- Available on iOS & Android
eBook - ePub
Learning Go Programming
Build ScalableNext-Gen Web Application using Golang (English Edition)
About this book
Appreciate the learning path to C Key Features
- Strengthens the foundations, as a detailed explanation of programming language concepts are given
- Lists down all the important points that you need to know related to various topics in an organized manner
- Provides In-depth explanation of complex topics
- Focuses on how to think logically to solve a problem
-
Description
Best way to learn any programming language is to create good programs in it. C is not an exception to this rule. Once you decide to write any program you would find that there are always at least two ways to write it. So you need to find out whether you have chosen the best way to implement your program, That's where you would find this book useful. It contains solutions to all the exercises present in Let Us C 17th Edition. If you learn the language elements form Let Us C, write programs for the problems given in the exercises and then cross check your answers with the solutions given in this book you would be well on your way to become a skilled C programmer. What will you learn
- C Instructions
- Decision Control Instruction, Loop Control Instruction, Case Control Instruction
- Functions, Pointers, Recursion
- Data Types, The C Preprocessor
- Arrays, Strings
- Structures, Console Input/Output, File Input/Output
-
Who this book is for
Students, Programmers, researchers, and software developers who wish to learn the basics of C programming language. Table of Contents
1. Introduction
2. Before We Begin...
3. Getting Started
4. C Instructions
5. Decision Control Instruction
6. More Complex Decision Making
7. Loop Control Instruction
8. More Complex Repetitions
9. Case Control Instruction
10. Functions
11. Pointers
12. Recursion
13. Data Types Revisited
14. The C Preprocessor
15. Arrays
16. Multidimensional Arrays
17. Strings
18. Handling Multiple Strings
19. Structures
20. Console Input/Output
21. File Input/Output
22. More Issues In Input/Output
23. Operations On Bits
24. Miscellaneous Features
25. Periodic Tests - I, II, III, IV About the Authors
Through his books and Quest Video Courses on C, C++, Java, Python, Data Structures, .NET, IoT, etc. Yashavant Kanetkar has created, molded and groomed lacs of IT careers in the last three decades. Yashavant's books and Quest videos have made a significant contribution in creating top-notch IT manpower in India and abroad.Yashavant's books are globally recognized and millions of students/professionals have benefitted from them. Yashavant's books have been translated into Hindi, Gujarati, Japanese, Korean and Chinese languages. Many of his books are published in India, USA, Japan, Singapore, Korea and China.Yashavant is a much sought after speaker in the IT field and has conducted seminars/workshops at TedEx, IITs, IIITs, NITs and global software companies.Yashavant has been honored with the prestigious "Distinguished Alumnus Award" by IIT Kanpur for his entrepreneurial, professional and academic excellence. This award was given to top 50 alumni of IIT Kanpur who have made a significant contribution towards their profession and betterment of society in the last 50 years. In recognition of his immense contribution to IT education in India, he has been awarded the "Best.NET Technical Contributor" and "Most Valuable Professional" awards by Microsoft for 5 successive years.Yashavant holds a BE from VJTI Mumbai and M.Tech. from IIT Kanpur. Yadhavant's current affiliations include being a Director of KICIT Pvt Ltd. And KSET Pvt Ltd.
Frequently asked questions
Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Perlego offers two plans: Essential and Complete
- Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
- Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, weâve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere â even offline. Perfect for commutes or when youâre on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access Learning Go Programming by Shubhangi Agarwal in PDF and/or ePUB format, as well as other popular books in Computer Science & Information Technology. We have over one million books available in our catalogue for you to explore.
Information
CHAPTER 1
Introduction to Go
Programming languages enable us to communicate with computers by developing various types of programs and applications. We have multiple programming languages in our technical world such as C, C++, PHP, Python, Ruby, and many others. Go language is one of those growing programming languages that solves many issues that we get from the other languages. Letâs go through the evolution of the Go language, its features, scope, and use in the technical field.
Structure
In this chapter, we will discuss the following topics:
- Software essence
- Evolution of Go language and its success
- Characteristics of Go language
- Object-oriented nature of Go language
- The analogy with other languages
- Pain points of Go language
- Application of Go language
Objective
After studying this chapter, youâll be able to understand the:
- Evaluation of Go language
- Need for Go language
- Characteristics of Go language
- How it is different from other programming languages
- Applications developed in Go language
A look at software essence
At the time of Goâs initiation, complexity was the major concern in software development. Usually, development used to be done by C++ or Java but there were some challenges with them like security, memory utilization, speed, efficiency, debugging, etc. Software should have the power to function correctly against potential risks produced by malicious attacks. Dead objects shouldnât exist to avoid resource blocking and improve the efficiency of software.
Evolution of Golang and its success
By looking at the problems with software development, it was decided that with a rise of networked and multicore computing, a language must support some sort of concurrency and parallelism, garbage collection, and should automate memory management. All that reflected into a thread of discussion, a bunch of ideas, decent strategy, and finally a great development. With Golang, efficient compilation, execution, and ease of programming are all possible with one language.
Go language is sponsored by Google and created by Robert Griesemer, Rob Pike, and Ken Thompson have depicted the goals of Golang. It finally came out in public on November 10, 2009. It is an open-source language. Go languageâs creators and the community have built many tools which are natively supported by the language core, that in most cases donât need any third-party library. For example, Go language has HTTP, JSON, HTML template, built-in language natively, and it can build very complex API services without even thinking about finding a library on GitHub. Now, millions of programmers are working on Go and many more are to come.

Figure 1.1: Logo change in April 2018
Characteristics of Go
Go is a statically and fast-compiled language that is designed to be used with multicore architecture for efficient memory utilization. Here are some features of Golang:
- Automatic garbage collection With this feature, the programmer does not need to worry about how the memory will be managed all around. Currently, âmark-and-sweepâ collector is used in Go. It keeps track of all the created objects. Whenever necessary, it first pauses the running process, works on garbage objects, and then frees the process to run again. It also supports concurrency.
- Concurrency To run more than one task simultaneously is called concurrency. Golang provides a different approach to execute multiple functions at the same time. That is possible with Goroutines and channels. In Go, Goroutines can be considered as the functions that can be executed parallelly with other functions. On the other hand, the channel provides functionality to communicate between multiple Goroutines.
- Static Golang is built as a compiled language, and Google developers did a great job with it. Using static linking, it combines all dependent libraries and modules into one single binary file based on OS type and architecture which means that while compiling the backend application, just upload the compiled binary into the server and it will work without installing any dependencies there.
- Ease testing Go language offers a rich library that supports automated testing. Here is a package called
testingthat helps to run the gotestcommand which makes the execution of any testing function possible. There are some benchmarks. There are many forms of testing functions that are executed by gotestcommands. - Standard library The important part of good programming is code reusability. The standard library of Go language contains a huge number of packages that provide great functionality for Go applications. It provides packages like OS, runtime, HTTP, XML, and JSON that connect with operating systems and give support for runtime.
- Cross-platform Go is a cross-platform language that can run on Linux, Mac, Free BSD, Windows, iOS, Android, and others.
- Documentation Golang has a command
Godocthat concentrates on package documentation and serves it as HTML or plain text. With the help of this documentation, the programmer can steer from illustration to the implementation of any function. It defines a packageâs functions, constants, variables, and even the type that Go supports.
Object-oriented nature
A standard definition of object-oriented language doesnât work with Go but it provides the same functionality in some other manner. There is a defined data structure
struct that integrates fields and methods. Golang has no inheritance but it has a different approach to establish the relation between structs. Object composition establishes a IS-A relationship, whereas interfaces are used to form Has-A relation.Furthermore, methods in the Go language are more transparent. They are not bound with structs. Go doesnât support the feature of overloading. In this way, Go language makes things simpler and more convenient.
The analogy with other languages
In C++, Java, and other object-oriented languages, inheritance, overloading, and generic types are the key features. Here, the Go team focuses on concurrency, garbage collection, and fast compilation to work well with parallel systems. Letâs go through some nuts and bolts of the programming language:
- Type-safe This refers to a feature to prevent â
typeâ errors. Just like C, C++, Java, and Python, Go is also a type-safe language. The Go compiler meets a certain level of validity at the time of compilation. It ensures that if there is â+â operator, then both the operands are of numeric type. - Object-oriented Go can be considered as a light-weight object-oriented language. However, it supports types and methods that can be defined for any sort of data but have no classes and inheritance. Not everything is an object associated here. Go syntax resembles the C language. It is statically typed and scalable to larger systems like C++ and Java.
- Inheritance Go is not an object-oriented language. It doesnât support inheritance but it has a feature of composition and interfaces. With composition, it is possible to embed more than two structs together. Multiple methods can be added in interface, and thus, it has a chance to grow. This new concept is more powerful than the class-based inheritance.
- Overloading Go doesnât have a concept of method and operator overloading unlike C++ and Java. Identifying methods by only their name removes complexity and makes it simple to code.
- Exception handling Unlike C++ and Java, there are no try-catch-finally idioms in Go. It has some built-in functions to signal and recover the exceptional conditions. Go functions return the error as the last value. Here is a simple mechanism: the last value is compared to ânil.â If it is, there is no error; otherwise, there would be an error.
- Concurrency In Java, there is an option of threads for concurrent programming. Java has a lot of utilities to manage those threads but still, it is considered quite expensive and hard to understand. To make it simple, Go has a simple technique for concurrency with the feature of Go routines and channels. Go routines are light-weighted threads, and the channel helps to communicate between Go routines.
- Garbage collection Generally, there are two ways of memory management. One is automatic reference counting and the other one is a garbage collection. Like C# and Java, Go also has a garbage collector. With Objective-C, Swift uses the reference counting technique to manage the resources. Current GC âmark-and-sweepâ is used with Go language. It runs on a separate CPU, parallel with main programs, and thus, it helps with multicore architectures.
Pain points of Go language
With multiple features, Golang has some disadvantages. The limitations of Go language are as follows:
- Generic Programming Go doesnât have compile-time generics that lead duplicate code or typecast as per requirement. However, there are first-class functions but we canât reuse the same functions with a different type of collection. It somehow affects efficiency and productivity as well.
- Tedious error handling Error handling is not perfect in the Go language. There is no execution carried out from the compiler to handle the error. It depends on the programmer as to how the functions can be used to return the error whenever it occurs.
Applications of Golang
Go has been gaining popularity since it was first announced in 2009. A few companies are working on the Go language such as IBM, Twitter, Facebook, YouTube, Apple, BBC, Google, and many others. No one can predict the future, but Golang has multiple reasons to grow.
Here are some applications that are developed in the Go language.
- Docker It is a set of tools to create, deploy, and run the distributed application.It is an open-source platform that allows the extending of its features if needed.
- OpenShift An open-source cloud comp...
Table of contents
- Cover Page
- Title Page
- Copyright Page
- Dedication Page
- About the Author
- About the Reviewer
- Acknowledgement
- Preface
- Errata
- Table of Contents
- 1. Introduction to Go
- 2. Environment Setup
- 3. Beginning With Go
- 4. Variables, Data Types, and Constants
- 5. Operators
- 6. Control Structures
- 7. Functions
- 8. Packages in Go
- 9. Arrays and Slices
- 10. Strings
- 11. Pointers
- 12. Structures
- 13. Composition
- 14. Interfaces and Polymorphism
- 15. Maps
- 16. Concurrency with Go
- 17. Mutex and Channels
- 18. Error Handling
- 19. Reflection
- 20. Building Web Application
- Index