Example: bachelor of science

Go Programming - Tutorialspoint

Go Programming i About the Tutorial Go language is a Programming language initially developed at Google in the year 2007 by Robert Griesemer, Rob Pike, and Ken Thompson. It is a statically-typed language having syntax similar to that of C. It provides garbage collection, type safety, dynamic-typing capability, many advanced built-in types such as variable length arrays and key-value maps. It also provides a rich standard library. The Go Programming language was launched in November 2009 and is used in some of the Google's production systems. Audience This tutorial is designed for software programmers with a need to understand the Go Programming language from scratch.

Go Programming 7 Go is a general-purpose language designed with systems programming in mind. It was initially developed at Google in the year …

Tags:

  Programming, Tutorialspoint, Go programming

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of Go Programming - Tutorialspoint

1 Go Programming i About the Tutorial Go language is a Programming language initially developed at Google in the year 2007 by Robert Griesemer, Rob Pike, and Ken Thompson. It is a statically-typed language having syntax similar to that of C. It provides garbage collection, type safety, dynamic-typing capability, many advanced built-in types such as variable length arrays and key-value maps. It also provides a rich standard library. The Go Programming language was launched in November 2009 and is used in some of the Google's production systems. Audience This tutorial is designed for software programmers with a need to understand the Go Programming language from scratch.

2 This tutorial will give you enough understanding on Go Programming language from where you can take yourself to higher levels of expertise. Prerequisites Before proceeding with this tutorial, you should have a basic understanding of computer Programming terminologies. If you have a good command over C, then it would be quite easy for you to understand the concepts of Go Programming and move fast on the learning track. Disclaimer & Copyright Copyright 2015 by Tutorials Point (I) Pvt. Ltd. All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher.

3 We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or in this tutorial, please notify us at Go Programming ii Table of Contents About the Tutorial .. i Audience .. i Prerequisites .. i Table of Contents .. ii 1. GO Programming OVERVIEW .. 1 Features of Go Programming .. 1 Features Excluded Intentionally .. 1 Go Programs .. 1 Compiling and Executing Go Programs.

4 2 2. GO Programming ENVIRONMENT SETUP .. 3 Try it Option Online .. 3 Local Environment Setup .. 3 Text Editor .. 3 The Go Compiler .. 4 Download Go Archive .. 4 Installation on UNIX/Linux/Mac OS X, and FreeBSD .. 4 Installation on Windows .. 5 Verifying the 5 3. GO Programming PROGRAM STRUCTURE .. 6 Hello World Example .. 6 Executing a Go Program .. 7 4. GO Programming BASIC SYNTAX .. 8 Tokens in Go .. 8 Line Separator .. 8 Comments .. 8 Go Programming iii Identifiers .. 9 Keywords .. 9 Whitespace in Go .. 9 5. GO Programming DATA TYPES .. 11 Integer Types .. 11 Floating Types .. 12 Other Numeric Types .. 12 6. GO Programming VARIABLES .. 14 Variable Definition in Go .. 14 Static Type Declaration in Go.

5 15 Dynamic Type Declaration / Type Inference in Go .. 16 Mixed Variable Declaration in Go .. 16 The lvalues and the rvalues in 17 7. GO Programming CONSTANTS .. 18 Integer Literals .. 18 Floating-point Literals .. 18 Escape Sequence .. 19 String Literals in Go .. 20 The const 20 8. GO Programming OPERATORS .. 22 Arithmetic Operators .. 22 Relational Operators .. 24 Logical Operators .. 26 Bitwise Operators .. 27 Assignment Operators .. 30 Miscellaneous Operators .. 32 Go Programming iv Operators Precedence in Go .. 33 9. GO Programming DECISION MAKING .. 36 The if Statement .. 37 The Statement .. 38 Nested if Statement .. 40 The Switch Statement .. 41 The Select Statement.

6 45 The Statement .. 46 10. GO Programming LOOPS .. 49 for Loop .. 49 Nested for Loops .. 53 Loop Control Statements .. 55 The continue Statement .. 57 The goto Statement .. 59 The Infinite Loop .. 61 11. GO Programming FUNCTIONS .. 63 Defining a Function .. 63 Calling a Function .. 64 Returning Multiple Values from Function .. 65 Function Arguments .. 66 Call by Value .. 66 Call by Reference .. 68 Function Usage .. 70 Function Closures .. 71 Method .. 72 12. GO Programming SCOPE RULES .. 74 Go Programming v Local Variables .. 74 Global Variables .. 75 Formal Parameters .. 76 Initializing Local and Global Variables .. 77 13. GO Programming STRINGS .. 78 Creating Strings.

7 78 String Length .. 79 Concatenating Strings .. 79 14. GO Programming ARRAYS .. 81 Declaring Arrays .. 81 Initializing Arrays .. 81 Accessing Array Elements .. 82 Go Arrays in Detail .. 83 Multidimensional Arrays in Go .. 83 Two-Dimensional Arrays .. 84 Initializing Two-Dimensional Arrays .. 84 Accessing Two-Dimensional Array Elements .. 84 Passing Arrays to Functions .. 86 15. GO Programming POINTERS .. 89 What Are Pointers? .. 89 How to Use Pointers?.. 90 Nil Pointers in Go .. 91 Go Pointers in Detail .. 91 Go Array of Pointers .. 92 Go Pointer to Pointer .. 93 Go Passing Pointers to Functions .. 95 Go Programming vi 16. GO Programming STRUCTURES .. 97 Defining a Structure.

8 97 Accessing Structure Members .. 97 Structures as Function Arguments .. 99 Pointers to Structures .. 101 17. GO Programming SLICES .. 103 Defining a slice .. 103 len() and cap() functions .. 103 Nil slice .. 104 Subslicing .. 104 append() and copy() Functions .. 106 18. GO Programming RANGE .. 108 19. GO Programming MAPS .. 110 Defining a Map .. 110 delete() 111 20. GO Programming RECURSION .. 113 Examples of Recursion in Go .. 113 21. GO Programming TYPE CASTING .. 115 22. GO Programming INTERFACES .. 116 23. GO Programming ERROR HANDLING .. 119 Go Programming 7 Go is a general-purpose language designed with systems Programming in mind. It was initially developed at Google in the year 2007 by Robert Griesemer, Rob Pike, and Ken Thompson.

9 It is strongly and statically typed, provides inbuilt support for garbage collection, and supports concurrent Programming . Programs are constructed using packages, for efficient management of dependencies. Go Programming implementations use a traditional compile and link model to generate executable binaries. The Go Programming language was announced in November 2009 and is used in some of the Google's production systems. Features of Go Programming The most important features of Go Programming are listed below: Support for environment adopting patterns similar to dynamic languages. For example, type inference (x := 0 is valid declaration of a variable x of type int) Compilation time is fast.

10 Inbuilt concurrency support: lightweight processes (via go routines), channels, select statement. Go programs are simple, concise, and safe. Support for Interfaces and Type embedding. Production of statically linked native binaries without external dependencies. Features Excluded Intentionally To keep the language simple and concise, the following features commonly available in other similar languages are omitted in Go: Support for type inheritance Support for method or operator overloading Support for circular dependencies among packages Support for pointer arithmetic Support for assertions Support for generic Programming 1. GO Programming Overview Go Programming 8 Go Programs A Go program can vary in length from 3 lines to millions of lines and it should be written into one or more text files with the extension ".


Related search queries