<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Hmarfat</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Hmarfat"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Hmarfat"/>
	<updated>2026-08-07T03:51:41Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss&amp;diff=91987</id>
		<title>CSC/ECE 517 Fall 2014/final design doc M1451 hsss</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss&amp;diff=91987"/>
		<updated>2014-11-12T02:55:49Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Appendix */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains details on the planned course of actions for the project on [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;b&amp;gt;About Servo&amp;lt;ref&amp;gt; https://www.mozilla.org/en-US/research/projects/&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Servo is an project to build a Web browser engine for a new generation of hardware. With Servo, we are rethinking the browser at every level of the technology stack — from input parsing to page layout to graphics rendering — to optimize for power efficiency and maximum parallelism.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;About Rust&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Rust_%28programming_language%29&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The goal of Rust is to be a good language for the creation of large client and server programs that run over the Internet. This has led to a feature set with an emphasis on safety, control of memory layout and concurrency. Performance of safe code is expected to be slower than C++ if performance is the only consideration, but to be comparable to C++ code that manually takes precautions comparable to what the Rust language mandates.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Purpose&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
This project is about implementing a protocol to define rules regarding the nature of data being sent/receive between the web page and the server built on a Mozilla Framework. We started by creating a WebSocket interface and its corresponding Rust implementation. The constructor of this interface returns a WebSocket object which will help us in establishing a basic HTTP connection to the server. Thereafter we plan to implement methods like close, open on the API along with the onopen and onclose events. &lt;br /&gt;
&lt;br /&gt;
This WebSocket interface runs on a [https://github.com/servo/servo Servo] engine. It is basically a prototype web browser engine written in the [https://github.com/rust-lang/rust Rust] language. It is currently developed on 64bit OS X and 64bit Linux. Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a&lt;br /&gt;
solid, embedded engine.&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/WebSocket-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
1. The initial step required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Then we had to build the rust compiler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. To build the servo, we cloned the source code into the local repository.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Then we created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/comms.html&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
9. After making all the changes we build are changes into servo. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
10. This was Part One of our project, which was a part of our OSS project.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
11. Part Two is our final project and is an extension of our OSS project.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
12. Now we will create a constructor which will return an WebSocket object and initiate a basic connection with the server. There are couple of sub parts we will need here:&lt;br /&gt;
*A ws scheme protocol handler (just as we have an http scheme protocol handler) that will implement the WS-specific parts of the connection process.&lt;br /&gt;
&lt;br /&gt;
*The ws protocol load method should transparently delegate the initial HTTP connection to http_loader::factory(); this way we do not need to duplicate the HTTP protocol code.&lt;br /&gt;
&lt;br /&gt;
*Using the same technique as the [http://en.wikipedia.org/wiki/MIME MIME] sniffing project, the WS load method should intercept the response from the HTTP load. This will allow us to look at the HTTP response and verify the presence of the required Upgrade header as described in the spec before sending the connection results to the WebSocket implementation&lt;br /&gt;
&lt;br /&gt;
13. In order to allow writing more data to the existing socket connection, we plan to make the stream member in the BufferedResponse in rust-http public. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
14. We have to implement closing of connection along with on open and inclose events. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
15. Furthermore, we have to implement sending simple short strings that fit within a single frame, receiving simple data and sending fragmented payloads across multiple frames.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
Flowchart:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Workflow.png]]&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Singleton Pattern ===&lt;br /&gt;
We are using [http://en.wikipedia.org/wiki/Singleton_pattern &amp;quot;Singleton Pattern&amp;quot;] because it will confine the instantiation of class 'WebSocket' to only one object. This ensures that the instance can be accessed from everywhere and hence provide a global point of access.&lt;br /&gt;
&lt;br /&gt;
=== Adapter Pattern ===&lt;br /&gt;
We are using [http://en.wikipedia.org/wiki/Adapter_pattern &amp;quot;Adapter Pattern&amp;quot;] to convert the interface of class 'WebSocket' into another interface that the caller expects. &amp;quot;Adapter pattern&amp;quot; allows other classes with incompatible interfaces to work together with class 'WebSocket', which is solely responsible to enable Web applications to maintain bidirectional communications with server-side processes.&lt;br /&gt;
&lt;br /&gt;
== UML diagram: UseCase Diagram ==&lt;br /&gt;
[[File:UseCaseDiagram_websocket.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Use Cases:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*Create a web socket object:&lt;br /&gt;
This object allows a basic connection to the server.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*Call the onopen function:&lt;br /&gt;
Connection along with on open event.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*Call the onclose function:&lt;br /&gt;
Connection along with on close event.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*Call the onmessage function:&lt;br /&gt;
Receiving of simple data and the on message event.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*Call the send function:&lt;br /&gt;
Sends fragmented data.&lt;br /&gt;
&lt;br /&gt;
==Proposed Test Cases==&lt;br /&gt;
&lt;br /&gt;
*Validating the url used to create a websocket object.&lt;br /&gt;
&lt;br /&gt;
*Checking if the connection with the remote server is established.&lt;br /&gt;
&lt;br /&gt;
*Check with session variables are reset on creating a new connection.&lt;br /&gt;
&lt;br /&gt;
*Check if the data if the messages are delivered to the remote host.&lt;br /&gt;
&lt;br /&gt;
*When the user agent validates the server's response during the &amp;quot;establish a WebSocket connection&amp;quot; algorithm, if the status code received from the server is not 101 (e.g. it is a redirect), it must fail the WebSocket connection.&lt;br /&gt;
&lt;br /&gt;
==Appendix==&lt;br /&gt;
&lt;br /&gt;
*Steps used for [https://github.com/rust-lang/rust/wiki/Note-getting-started-developing-Rust Installing Rust].&lt;br /&gt;
&lt;br /&gt;
*Steps used for [https://github.com/servo/servo Building Servo].&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss&amp;diff=91984</id>
		<title>CSC/ECE 517 Fall 2014/final design doc M1451 hsss</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss&amp;diff=91984"/>
		<updated>2014-11-12T02:54:17Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains details on the planned course of actions for the project on [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;b&amp;gt;About Servo&amp;lt;ref&amp;gt; https://www.mozilla.org/en-US/research/projects/&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Servo is an project to build a Web browser engine for a new generation of hardware. With Servo, we are rethinking the browser at every level of the technology stack — from input parsing to page layout to graphics rendering — to optimize for power efficiency and maximum parallelism.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;About Rust&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Rust_%28programming_language%29&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The goal of Rust is to be a good language for the creation of large client and server programs that run over the Internet. This has led to a feature set with an emphasis on safety, control of memory layout and concurrency. Performance of safe code is expected to be slower than C++ if performance is the only consideration, but to be comparable to C++ code that manually takes precautions comparable to what the Rust language mandates.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Purpose&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
This project is about implementing a protocol to define rules regarding the nature of data being sent/receive between the web page and the server built on a Mozilla Framework. We started by creating a WebSocket interface and its corresponding Rust implementation. The constructor of this interface returns a WebSocket object which will help us in establishing a basic HTTP connection to the server. Thereafter we plan to implement methods like close, open on the API along with the onopen and onclose events. &lt;br /&gt;
&lt;br /&gt;
This WebSocket interface runs on a [https://github.com/servo/servo Servo] engine. It is basically a prototype web browser engine written in the [https://github.com/rust-lang/rust Rust] language. It is currently developed on 64bit OS X and 64bit Linux. Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a&lt;br /&gt;
solid, embedded engine.&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/WebSocket-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
1. The initial step required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Then we had to build the rust compiler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. To build the servo, we cloned the source code into the local repository.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Then we created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/comms.html&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
9. After making all the changes we build are changes into servo. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
10. This was Part One of our project, which was a part of our OSS project.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
11. Part Two is our final project and is an extension of our OSS project.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
12. Now we will create a constructor which will return an WebSocket object and initiate a basic connection with the server. There are couple of sub parts we will need here:&lt;br /&gt;
*A ws scheme protocol handler (just as we have an http scheme protocol handler) that will implement the WS-specific parts of the connection process.&lt;br /&gt;
&lt;br /&gt;
*The ws protocol load method should transparently delegate the initial HTTP connection to http_loader::factory(); this way we do not need to duplicate the HTTP protocol code.&lt;br /&gt;
&lt;br /&gt;
*Using the same technique as the [http://en.wikipedia.org/wiki/MIME MIME] sniffing project, the WS load method should intercept the response from the HTTP load. This will allow us to look at the HTTP response and verify the presence of the required Upgrade header as described in the spec before sending the connection results to the WebSocket implementation&lt;br /&gt;
&lt;br /&gt;
13. In order to allow writing more data to the existing socket connection, we plan to make the stream member in the BufferedResponse in rust-http public. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
14. We have to implement closing of connection along with on open and inclose events. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
15. Furthermore, we have to implement sending simple short strings that fit within a single frame, receiving simple data and sending fragmented payloads across multiple frames.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
Flowchart:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Workflow.png]]&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Singleton Pattern ===&lt;br /&gt;
We are using [http://en.wikipedia.org/wiki/Singleton_pattern &amp;quot;Singleton Pattern&amp;quot;] because it will confine the instantiation of class 'WebSocket' to only one object. This ensures that the instance can be accessed from everywhere and hence provide a global point of access.&lt;br /&gt;
&lt;br /&gt;
=== Adapter Pattern ===&lt;br /&gt;
We are using [http://en.wikipedia.org/wiki/Adapter_pattern &amp;quot;Adapter Pattern&amp;quot;] to convert the interface of class 'WebSocket' into another interface that the caller expects. &amp;quot;Adapter pattern&amp;quot; allows other classes with incompatible interfaces to work together with class 'WebSocket', which is solely responsible to enable Web applications to maintain bidirectional communications with server-side processes.&lt;br /&gt;
&lt;br /&gt;
== UML diagram: UseCase Diagram ==&lt;br /&gt;
[[File:UseCaseDiagram_websocket.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Use Cases:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*Create a web socket object:&lt;br /&gt;
This object allows a basic connection to the server.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*Call the onopen function:&lt;br /&gt;
Connection along with on open event.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*Call the onclose function:&lt;br /&gt;
Connection along with on close event.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*Call the onmessage function:&lt;br /&gt;
Receiving of simple data and the on message event.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*Call the send function:&lt;br /&gt;
Sends fragmented data.&lt;br /&gt;
&lt;br /&gt;
==Proposed Test Cases==&lt;br /&gt;
&lt;br /&gt;
*Validating the url used to create a websocket object.&lt;br /&gt;
&lt;br /&gt;
*Checking if the connection with the remote server is established.&lt;br /&gt;
&lt;br /&gt;
*Check with session variables are reset on creating a new connection.&lt;br /&gt;
&lt;br /&gt;
*Check if the data if the messages are delivered to the remote host.&lt;br /&gt;
&lt;br /&gt;
==Appendix==&lt;br /&gt;
&lt;br /&gt;
-Steps used for [https://github.com/rust-lang/rust/wiki/Note-getting-started-developing-Rust Installing Rust].&lt;br /&gt;
&lt;br /&gt;
-Steps used for [https://github.com/servo/servo Building Servo].&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss&amp;diff=91982</id>
		<title>CSC/ECE 517 Fall 2014/final design doc M1451 hsss</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss&amp;diff=91982"/>
		<updated>2014-11-12T02:51:45Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains details on the planned course of actions for the project on [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;b&amp;gt;About Servo&amp;lt;ref&amp;gt; https://www.mozilla.org/en-US/research/projects/&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Servo is an project to build a Web browser engine for a new generation of hardware. With Servo, we are rethinking the browser at every level of the technology stack — from input parsing to page layout to graphics rendering — to optimize for power efficiency and maximum parallelism.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;About Rust&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Rust_%28programming_language%29&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The goal of Rust is to be a good language for the creation of large client and server programs that run over the Internet. This has led to a feature set with an emphasis on safety, control of memory layout and concurrency. Performance of safe code is expected to be slower than C++ if performance is the only consideration, but to be comparable to C++ code that manually takes precautions comparable to what the Rust language mandates.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Purpose&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
This project is about implementing a protocol to define rules regarding the nature of data being sent/receive between the web page and the server built on a Mozilla Framework. We started by creating a WebSocket interface and its corresponding Rust implementation. The constructor of this interface returns a WebSocket object which will help us in establishing a basic HTTP connection to the server. Thereafter we plan to implement methods like close, open on the API along with the onopen and onclose events. &lt;br /&gt;
&lt;br /&gt;
This WebSocket interface runs on a [https://github.com/servo/servo Servo] engine. It is basically a prototype web browser engine written in the [https://github.com/rust-lang/rust Rust] language. It is currently developed on 64bit OS X and 64bit Linux. Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a&lt;br /&gt;
solid, embedded engine.&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/WebSocket-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
1. The initial step required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Then we had to build the rust compiler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. To build the servo, we cloned the source code into the local repository.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Then we created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/comms.html&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
9. After making all the changes we build are changes into servo. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
10. This was Part One of our project, which was a part of our OSS project.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
11. Part Two is our final project and is an extension of our OSS project.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
12. Now we will create a constructor which will return an WebSocket object and initiate a basic connection with the server. There are couple of sub parts we will need here:&lt;br /&gt;
*A ws scheme protocol handler (just as we have an http scheme protocol handler) that will implement the WS-specific parts of the connection process.&lt;br /&gt;
&lt;br /&gt;
*The ws protocol load method should transparently delegate the initial HTTP connection to http_loader::factory(); this way we do not need to duplicate the HTTP protocol code.&lt;br /&gt;
&lt;br /&gt;
*Using the same technique as the [http://en.wikipedia.org/wiki/MIME MIME] sniffing project, the WS load method should intercept the response from the HTTP load. This will allow us to look at the HTTP response and verify the presence of the required Upgrade header as described in the spec before sending the connection results to the WebSocket implementation&lt;br /&gt;
&lt;br /&gt;
13. In order to allow writing more data to the existing socket connection, we plan to make the stream member in the BufferedResponse in rust-http public. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
14. We have to implement closing of connection along with on open and inclose events. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
15. Furthermore, we have to implement sending simple short strings that fit within a single frame, receiving simple data and sending fragmented payloads across multiple frames.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
Flowchart:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Workflow.png]]&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Singleton Pattern ===&lt;br /&gt;
We are using [http://en.wikipedia.org/wiki/Singleton_pattern &amp;quot;Singleton Pattern&amp;quot;] because it will confine the instantiation of class 'WebSocket' to only one object. This ensures that the instance can be accessed from everywhere and hence provide a global point of access.&lt;br /&gt;
&lt;br /&gt;
=== Adapter Pattern ===&lt;br /&gt;
We are using [http://en.wikipedia.org/wiki/Adapter_pattern &amp;quot;Adapter Pattern&amp;quot;] to convert the interface of class 'WebSocket' into another interface that the caller expects. &amp;quot;Adapter pattern&amp;quot; allows other classes with incompatible interfaces to work together with class 'WebSocket', which is solely responsible to enable Web applications to maintain bidirectional communications with server-side processes.&lt;br /&gt;
&lt;br /&gt;
== UML diagram: UseCase Diagram ==&lt;br /&gt;
[[File:UseCaseDiagram_websocket.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Use Cases:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*Create a web socket object:&lt;br /&gt;
This object allows a basic connection to the server.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*Call the onopen function:&lt;br /&gt;
Connection along with on open event.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*Call the onclose function:&lt;br /&gt;
Connection along with on close event.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*Call the onmessage function:&lt;br /&gt;
Receiving of simple data and the on message event.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*Call the send function:&lt;br /&gt;
Sends fragmented data.&lt;br /&gt;
&lt;br /&gt;
==Proposed Test Cases==&lt;br /&gt;
&lt;br /&gt;
*Validating the url used to create a websocket object.&lt;br /&gt;
&lt;br /&gt;
*Checking if the connection with the remote server is established.&lt;br /&gt;
&lt;br /&gt;
*Check with session variables are reset on creating a new connection.&lt;br /&gt;
&lt;br /&gt;
*Check if the data if the messages are delivered to the remote host.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Websocket.jpg&amp;diff=91835</id>
		<title>File:Websocket.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Websocket.jpg&amp;diff=91835"/>
		<updated>2014-11-11T23:57:08Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Diagram_websocket.jpg&amp;diff=91833</id>
		<title>File:Diagram websocket.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Diagram_websocket.jpg&amp;diff=91833"/>
		<updated>2014-11-11T23:54:14Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Diagram_websocket.jpg]]&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Diagram_websocket.jpg&amp;diff=91832</id>
		<title>File:Diagram websocket.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Diagram_websocket.jpg&amp;diff=91832"/>
		<updated>2014-11-11T23:53:44Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:WorkflowChart.png&amp;diff=91831</id>
		<title>File:WorkflowChart.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:WorkflowChart.png&amp;diff=91831"/>
		<updated>2014-11-11T23:50:39Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Workflow.png&amp;diff=91830</id>
		<title>File:Workflow.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Workflow.png&amp;diff=91830"/>
		<updated>2014-11-11T23:49:55Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Workflow.png]]&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Workflow.png&amp;diff=91829</id>
		<title>File:Workflow.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Workflow.png&amp;diff=91829"/>
		<updated>2014-11-11T23:49:18Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Screen_Shot_2014-11-11_at_6.44.22_PM.png&amp;diff=91827</id>
		<title>File:Screen Shot 2014-11-11 at 6.44.22 PM.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Screen_Shot_2014-11-11_at_6.44.22_PM.png&amp;diff=91827"/>
		<updated>2014-11-11T23:47:12Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: uploaded a new version of &amp;amp;quot;File:Screen Shot 2014-11-11 at 6.44.22 PM.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Screen_Shot_2014-11-11_at_6.44.22_PM.png&amp;diff=91821</id>
		<title>File:Screen Shot 2014-11-11 at 6.44.22 PM.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Screen_Shot_2014-11-11_at_6.44.22_PM.png&amp;diff=91821"/>
		<updated>2014-11-11T23:46:10Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91062</id>
		<title>CSC/ECE 517 Fall 2014/OSS M1451 ahs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91062"/>
		<updated>2014-10-30T01:04:59Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Design Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://docs.google.com/a/ncsu.edu/document/d/18VECpUuVmEaC4Xew4EsIAmOsRKdIeXaTA42tLlNwIho/edit Project Topic Page]&lt;br /&gt;
==  Implement the WebSocket API ==&lt;br /&gt;
This wiki page contains details on the work done for the initial step of the task of [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Rust &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Rust_(programming_language)&amp;lt;/ref&amp;gt;==&lt;br /&gt;
Rust is a curly-brace, block-structured expression language.&lt;br /&gt;
&lt;br /&gt;
*It visually resembles the C language family, but differs significantly in syntactic and semantic details. &lt;br /&gt;
&lt;br /&gt;
*Its design is oriented toward concerns of “programming in the large”, that is, of creating and maintaining boundaries – both abstract and operational – that preserve large-system integrity, availability and concurrency.&lt;br /&gt;
&lt;br /&gt;
*It supports a mixture of imperative procedural, concurrent actor, object-oriented and pure functional styles. Rust also supports generic programming and &lt;br /&gt;
metaprogramming, in both static and dynamic styles.&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fn main() {&lt;br /&gt;
    println!(&amp;quot;hello, world&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Servo &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Servo_(layout_engine)&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
Servo is an experimental web browser layout engine being developed by Mozilla.&lt;br /&gt;
&lt;br /&gt;
*The prototype seeks to create a highly parallel environment, in which many components (such as rendering, layout, HTML parsing, image decoding, etc.) are &lt;br /&gt;
handled by fine-grained, isolated tasks. &lt;br /&gt;
&lt;br /&gt;
*The project has a symbiotic relationship with the Rust programming language, in which it is being developed.&lt;br /&gt;
&lt;br /&gt;
*Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a &lt;br /&gt;
solid, embedded engine. Although Servo is a research project, it is designed to be &amp;quot;productisable&amp;quot;—the code that we write should be of high enough quality that it could eventually be shipped to users.&lt;br /&gt;
&lt;br /&gt;
== Task Architecture Diagrams&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
=Implementation Steps=&lt;br /&gt;
We carried out the implementation for this project on a Mac machine. The steps we followed for the implementation are as follows:&lt;br /&gt;
&lt;br /&gt;
== Compiling Rust ==&lt;br /&gt;
1. The initial step to build Servo required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub using the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git://github.com/mozilla/rust.git&lt;br /&gt;
cd rust&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Use the following commands to build the Rust compiler:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
make check&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will build and test the compiler, standard libraries, and supporting tools.&lt;br /&gt;
&lt;br /&gt;
== Build Servo ==&lt;br /&gt;
1. Fork the servo repository and clone the source code into the local repository using the command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://github.com/servo/servo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Build servo using the following commands:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Part One Of the Project ==&lt;br /&gt;
&lt;br /&gt;
-Created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo. &lt;br /&gt;
&lt;br /&gt;
-We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project &amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/comms.html&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
-We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor. &lt;br /&gt;
&lt;br /&gt;
-We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
&lt;br /&gt;
-We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
&lt;br /&gt;
-After making all the changes we build are changes into servo.&lt;br /&gt;
&lt;br /&gt;
-Created a [https://github.com/servo/servo/pull/3813 pull request].&lt;br /&gt;
&lt;br /&gt;
= Future Goals for the Project =&lt;br /&gt;
&lt;br /&gt;
-Create a basic connection to the server using the websocket connection protocol as specified in the [http://tools.ietf.org/html/rfc6455#section-4.1 protocol spec].&lt;br /&gt;
&lt;br /&gt;
-In order to allow writing more data to the existing socket connection, we plan to make the stream member in the BufferedResponse in rust-http public.&lt;br /&gt;
&lt;br /&gt;
-Implement closing of connection along with on open and inclose events.&lt;br /&gt;
&lt;br /&gt;
-Implement sending of short simple strings which fit within a single frame.&lt;br /&gt;
&lt;br /&gt;
-Implement receiving of simple data and the on message event.&lt;br /&gt;
&lt;br /&gt;
-Implement sending of fragmented data.&lt;br /&gt;
&lt;br /&gt;
= Design Pattern =&lt;br /&gt;
&lt;br /&gt;
We plan to implement the Factory&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Factory_(object-oriented_programming)&amp;lt;/ref&amp;gt; design Pattern since out implementation of the WebSocket interface is a child of the EventTarget interface in Servo.&lt;br /&gt;
&lt;br /&gt;
= Appendix =&lt;br /&gt;
&lt;br /&gt;
-Steps for [https://github.com/rust-lang/rust/wiki/Note-getting-started-developing-Rust Installing Rust] in detail.&lt;br /&gt;
&lt;br /&gt;
-Steps for [https://github.com/servo/servo Building Servo] in detail.&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91057</id>
		<title>CSC/ECE 517 Fall 2014/OSS M1451 ahs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91057"/>
		<updated>2014-10-30T01:02:46Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://docs.google.com/a/ncsu.edu/document/d/18VECpUuVmEaC4Xew4EsIAmOsRKdIeXaTA42tLlNwIho/edit Project Topic Page]&lt;br /&gt;
==  Implement the WebSocket API ==&lt;br /&gt;
This wiki page contains details on the work done for the initial step of the task of [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Rust &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Rust_(programming_language)&amp;lt;/ref&amp;gt;==&lt;br /&gt;
Rust is a curly-brace, block-structured expression language.&lt;br /&gt;
&lt;br /&gt;
*It visually resembles the C language family, but differs significantly in syntactic and semantic details. &lt;br /&gt;
&lt;br /&gt;
*Its design is oriented toward concerns of “programming in the large”, that is, of creating and maintaining boundaries – both abstract and operational – that preserve large-system integrity, availability and concurrency.&lt;br /&gt;
&lt;br /&gt;
*It supports a mixture of imperative procedural, concurrent actor, object-oriented and pure functional styles. Rust also supports generic programming and &lt;br /&gt;
metaprogramming, in both static and dynamic styles.&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fn main() {&lt;br /&gt;
    println!(&amp;quot;hello, world&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Servo &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Servo_(layout_engine)&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
Servo is an experimental web browser layout engine being developed by Mozilla.&lt;br /&gt;
&lt;br /&gt;
*The prototype seeks to create a highly parallel environment, in which many components (such as rendering, layout, HTML parsing, image decoding, etc.) are &lt;br /&gt;
handled by fine-grained, isolated tasks. &lt;br /&gt;
&lt;br /&gt;
*The project has a symbiotic relationship with the Rust programming language, in which it is being developed.&lt;br /&gt;
&lt;br /&gt;
*Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a &lt;br /&gt;
solid, embedded engine. Although Servo is a research project, it is designed to be &amp;quot;productisable&amp;quot;—the code that we write should be of high enough quality that it could eventually be shipped to users.&lt;br /&gt;
&lt;br /&gt;
== Task Architecture Diagrams&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
=Implementation Steps=&lt;br /&gt;
We carried out the implementation for this project on a Mac machine. The steps we followed for the implementation are as follows:&lt;br /&gt;
&lt;br /&gt;
== Compiling Rust ==&lt;br /&gt;
1. The initial step to build Servo required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub using the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git://github.com/mozilla/rust.git&lt;br /&gt;
cd rust&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Use the following commands to build the Rust compiler:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
make check&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will build and test the compiler, standard libraries, and supporting tools.&lt;br /&gt;
&lt;br /&gt;
== Build Servo ==&lt;br /&gt;
1. Fork the servo repository and clone the source code into the local repository using the command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://github.com/servo/servo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Build servo using the following commands:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Part One Of the Project ==&lt;br /&gt;
&lt;br /&gt;
-Created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo. &lt;br /&gt;
&lt;br /&gt;
-We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project &amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/comms.html&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
-We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor. &lt;br /&gt;
&lt;br /&gt;
-We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
&lt;br /&gt;
-We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
&lt;br /&gt;
-After making all the changes we build are changes into servo.&lt;br /&gt;
&lt;br /&gt;
-Created a [https://github.com/servo/servo/pull/3813 pull request].&lt;br /&gt;
&lt;br /&gt;
= Future Goals for the Project =&lt;br /&gt;
&lt;br /&gt;
-Create a basic connection to the server using the websocket connection protocol as specified in the [http://tools.ietf.org/html/rfc6455#section-4.1 protocol spec].&lt;br /&gt;
&lt;br /&gt;
-In order to allow writing more data to the existing socket connection, we plan to make the stream member in the BufferedResponse in rust-http public.&lt;br /&gt;
&lt;br /&gt;
-Implement closing of connection along with on open and inclose events.&lt;br /&gt;
&lt;br /&gt;
-Implement sending of short simple strings which fit within a single frame.&lt;br /&gt;
&lt;br /&gt;
-Implement receiving of simple data and the on message event.&lt;br /&gt;
&lt;br /&gt;
-Implement sending of fragmented data.&lt;br /&gt;
&lt;br /&gt;
= Design Pattern =&lt;br /&gt;
&lt;br /&gt;
We plan to implement the Factory&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Factory_(object-oriented_programming)&amp;lt;/ref&amp;gt; design Pattern since out implementation of the WebSocket interface is a child of the EventTarget interface in servo.&lt;br /&gt;
&lt;br /&gt;
= Appendix =&lt;br /&gt;
&lt;br /&gt;
-Steps for [https://github.com/rust-lang/rust/wiki/Note-getting-started-developing-Rust Installing Rust] in detail.&lt;br /&gt;
&lt;br /&gt;
-Steps for [https://github.com/servo/servo Building Servo] in detail.&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91053</id>
		<title>CSC/ECE 517 Fall 2014/OSS M1451 ahs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91053"/>
		<updated>2014-10-30T00:58:18Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Design Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://docs.google.com/a/ncsu.edu/document/d/18VECpUuVmEaC4Xew4EsIAmOsRKdIeXaTA42tLlNwIho/edit Project Topic Page]&lt;br /&gt;
==  Implement the WebSocket API ==&lt;br /&gt;
This wiki page contains details on the work done for the initial step of the task of [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Rust &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Rust_(programming_language)&amp;lt;/ref&amp;gt;==&lt;br /&gt;
Rust is a curly-brace, block-structured expression language.&lt;br /&gt;
&lt;br /&gt;
*It visually resembles the C language family, but differs significantly in syntactic and semantic details. &lt;br /&gt;
&lt;br /&gt;
*Its design is oriented toward concerns of “programming in the large”, that is, of creating and maintaining boundaries – both abstract and operational – that preserve large-system integrity, availability and concurrency.&lt;br /&gt;
&lt;br /&gt;
*It supports a mixture of imperative procedural, concurrent actor, object-oriented and pure functional styles. Rust also supports generic programming and &lt;br /&gt;
metaprogramming, in both static and dynamic styles.&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fn main() {&lt;br /&gt;
    println!(&amp;quot;hello, world&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Servo &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Servo_(layout_engine)&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
Servo is an experimental web browser layout engine being developed by Mozilla.&lt;br /&gt;
&lt;br /&gt;
*The prototype seeks to create a highly parallel environment, in which many components (such as rendering, layout, HTML parsing, image decoding, etc.) are &lt;br /&gt;
handled by fine-grained, isolated tasks. &lt;br /&gt;
&lt;br /&gt;
*The project has a symbiotic relationship with the Rust programming language, in which it is being developed.&lt;br /&gt;
&lt;br /&gt;
*Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a &lt;br /&gt;
solid, embedded engine. Although Servo is a research project, it is designed to be &amp;quot;productisable&amp;quot;—the code that we write should be of high enough quality that it could eventually be shipped to users.&lt;br /&gt;
&lt;br /&gt;
== Task Architecture Diagrams&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
=Implementation Steps=&lt;br /&gt;
We carried out the implementation for this project on a Mac machine. The steps we followed for the implementation are as follows:&lt;br /&gt;
&lt;br /&gt;
== Compiling Rust ==&lt;br /&gt;
1. The initial step to build Servo required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub using the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git://github.com/mozilla/rust.git&lt;br /&gt;
cd rust&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Use the following commands to build the Rust compiler:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
make check&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will build and test the compiler, standard libraries, and supporting tools.&lt;br /&gt;
&lt;br /&gt;
== Build Servo ==&lt;br /&gt;
1. Fork the servo repository and clone the source code into the local repository using the command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://github.com/servo/servo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Build servo using the following commands:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Part One Of the Project ==&lt;br /&gt;
&lt;br /&gt;
-Created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo. &lt;br /&gt;
&lt;br /&gt;
-We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project &amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/comms.html&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
-We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor. &lt;br /&gt;
&lt;br /&gt;
-We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
&lt;br /&gt;
-We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
&lt;br /&gt;
-After making all the changes we build are changes into servo.&lt;br /&gt;
&lt;br /&gt;
= Future Goals for the Project =&lt;br /&gt;
&lt;br /&gt;
-Create a basic connection to the server using the websocket connection protocol as specified in the [http://tools.ietf.org/html/rfc6455#section-4.1 protocol spec].&lt;br /&gt;
&lt;br /&gt;
-In order to allow writing more data to the existing socket connection, we plan to make the stream member in the BufferedResponse in rust-http public.&lt;br /&gt;
&lt;br /&gt;
-Implement closing of connection along with on open and inclose events.&lt;br /&gt;
&lt;br /&gt;
-Implement sending of short simple strings which fit within a single frame.&lt;br /&gt;
&lt;br /&gt;
-Implement receiving of simple data and the on message event.&lt;br /&gt;
&lt;br /&gt;
-Implement sending of fragmented data.&lt;br /&gt;
&lt;br /&gt;
= Design Pattern =&lt;br /&gt;
&lt;br /&gt;
We plan to implement the Factory&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Factory_(object-oriented_programming)&amp;lt;/ref&amp;gt; design Pattern since out implementation of the WebSocket interface is a child of the EventTarget interface in servo.&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91049</id>
		<title>CSC/ECE 517 Fall 2014/OSS M1451 ahs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91049"/>
		<updated>2014-10-30T00:52:57Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Part One Of the Project */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://docs.google.com/a/ncsu.edu/document/d/18VECpUuVmEaC4Xew4EsIAmOsRKdIeXaTA42tLlNwIho/edit Project Topic Page]&lt;br /&gt;
==  Implement the WebSocket API ==&lt;br /&gt;
This wiki page contains details on the work done for the initial step of the task of [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Rust &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Rust_(programming_language)&amp;lt;/ref&amp;gt;==&lt;br /&gt;
Rust is a curly-brace, block-structured expression language.&lt;br /&gt;
&lt;br /&gt;
*It visually resembles the C language family, but differs significantly in syntactic and semantic details. &lt;br /&gt;
&lt;br /&gt;
*Its design is oriented toward concerns of “programming in the large”, that is, of creating and maintaining boundaries – both abstract and operational – that preserve large-system integrity, availability and concurrency.&lt;br /&gt;
&lt;br /&gt;
*It supports a mixture of imperative procedural, concurrent actor, object-oriented and pure functional styles. Rust also supports generic programming and &lt;br /&gt;
metaprogramming, in both static and dynamic styles.&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fn main() {&lt;br /&gt;
    println!(&amp;quot;hello, world&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Servo &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Servo_(layout_engine)&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
Servo is an experimental web browser layout engine being developed by Mozilla.&lt;br /&gt;
&lt;br /&gt;
*The prototype seeks to create a highly parallel environment, in which many components (such as rendering, layout, HTML parsing, image decoding, etc.) are &lt;br /&gt;
handled by fine-grained, isolated tasks. &lt;br /&gt;
&lt;br /&gt;
*The project has a symbiotic relationship with the Rust programming language, in which it is being developed.&lt;br /&gt;
&lt;br /&gt;
*Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a &lt;br /&gt;
solid, embedded engine. Although Servo is a research project, it is designed to be &amp;quot;productisable&amp;quot;—the code that we write should be of high enough quality that it could eventually be shipped to users.&lt;br /&gt;
&lt;br /&gt;
== Task Architecture Diagrams&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
=Implementation Steps=&lt;br /&gt;
We carried out the implementation for this project on a Mac machine. The steps we followed for the implementation are as follows:&lt;br /&gt;
&lt;br /&gt;
== Compiling Rust ==&lt;br /&gt;
1. The initial step to build Servo required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub using the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git://github.com/mozilla/rust.git&lt;br /&gt;
cd rust&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Use the following commands to build the Rust compiler:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
make check&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will build and test the compiler, standard libraries, and supporting tools.&lt;br /&gt;
&lt;br /&gt;
== Build Servo ==&lt;br /&gt;
1. Fork the servo repository and clone the source code into the local repository using the command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://github.com/servo/servo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Build servo using the following commands:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Part One Of the Project ==&lt;br /&gt;
&lt;br /&gt;
-Created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo. &lt;br /&gt;
&lt;br /&gt;
-We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project &amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/comms.html&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
-We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor. &lt;br /&gt;
&lt;br /&gt;
-We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
&lt;br /&gt;
-We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
&lt;br /&gt;
-After making all the changes we build are changes into servo.&lt;br /&gt;
&lt;br /&gt;
= Future Goals for the Project =&lt;br /&gt;
&lt;br /&gt;
-Create a basic connection to the server using the websocket connection protocol as specified in the [http://tools.ietf.org/html/rfc6455#section-4.1 protocol spec].&lt;br /&gt;
&lt;br /&gt;
-In order to allow writing more data to the existing socket connection, we plan to make the stream member in the BufferedResponse in rust-http public.&lt;br /&gt;
&lt;br /&gt;
-Implement closing of connection along with on open and inclose events.&lt;br /&gt;
&lt;br /&gt;
-Implement sending of short simple strings which fit within a single frame.&lt;br /&gt;
&lt;br /&gt;
-Implement receiving of simple data and the on message event.&lt;br /&gt;
&lt;br /&gt;
-Implement sending of fragmented data.&lt;br /&gt;
&lt;br /&gt;
= Design Pattern =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91048</id>
		<title>CSC/ECE 517 Fall 2014/OSS M1451 ahs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91048"/>
		<updated>2014-10-30T00:52:01Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Future Goals for the Project */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://docs.google.com/a/ncsu.edu/document/d/18VECpUuVmEaC4Xew4EsIAmOsRKdIeXaTA42tLlNwIho/edit Project Topic Page]&lt;br /&gt;
==  Implement the WebSocket API ==&lt;br /&gt;
This wiki page contains details on the work done for the initial step of the task of [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Rust &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Rust_(programming_language)&amp;lt;/ref&amp;gt;==&lt;br /&gt;
Rust is a curly-brace, block-structured expression language.&lt;br /&gt;
&lt;br /&gt;
*It visually resembles the C language family, but differs significantly in syntactic and semantic details. &lt;br /&gt;
&lt;br /&gt;
*Its design is oriented toward concerns of “programming in the large”, that is, of creating and maintaining boundaries – both abstract and operational – that preserve large-system integrity, availability and concurrency.&lt;br /&gt;
&lt;br /&gt;
*It supports a mixture of imperative procedural, concurrent actor, object-oriented and pure functional styles. Rust also supports generic programming and &lt;br /&gt;
metaprogramming, in both static and dynamic styles.&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fn main() {&lt;br /&gt;
    println!(&amp;quot;hello, world&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Servo &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Servo_(layout_engine)&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
Servo is an experimental web browser layout engine being developed by Mozilla.&lt;br /&gt;
&lt;br /&gt;
*The prototype seeks to create a highly parallel environment, in which many components (such as rendering, layout, HTML parsing, image decoding, etc.) are &lt;br /&gt;
handled by fine-grained, isolated tasks. &lt;br /&gt;
&lt;br /&gt;
*The project has a symbiotic relationship with the Rust programming language, in which it is being developed.&lt;br /&gt;
&lt;br /&gt;
*Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a &lt;br /&gt;
solid, embedded engine. Although Servo is a research project, it is designed to be &amp;quot;productisable&amp;quot;—the code that we write should be of high enough quality that it could eventually be shipped to users.&lt;br /&gt;
&lt;br /&gt;
== Task Architecture Diagrams&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
=Implementation Steps=&lt;br /&gt;
We carried out the implementation for this project on a Mac machine. The steps we followed for the implementation are as follows:&lt;br /&gt;
&lt;br /&gt;
== Compiling Rust ==&lt;br /&gt;
1. The initial step to build Servo required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub using the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git://github.com/mozilla/rust.git&lt;br /&gt;
cd rust&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Use the following commands to build the Rust compiler:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
make check&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will build and test the compiler, standard libraries, and supporting tools.&lt;br /&gt;
&lt;br /&gt;
== Build Servo ==&lt;br /&gt;
1. Fork the servo repository and clone the source code into the local repository using the command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://github.com/servo/servo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Build servo using the following commands:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Part One Of the Project ==&lt;br /&gt;
&lt;br /&gt;
-Created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo. &lt;br /&gt;
&lt;br /&gt;
-We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project.&lt;br /&gt;
&lt;br /&gt;
-We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor. &lt;br /&gt;
&lt;br /&gt;
-We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
&lt;br /&gt;
-We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
&lt;br /&gt;
-After making all the changes we build are changes into servo.&lt;br /&gt;
&lt;br /&gt;
= Future Goals for the Project =&lt;br /&gt;
&lt;br /&gt;
-Create a basic connection to the server using the websocket connection protocol as specified in the [http://tools.ietf.org/html/rfc6455#section-4.1 protocol spec].&lt;br /&gt;
&lt;br /&gt;
-In order to allow writing more data to the existing socket connection, we plan to make the stream member in the BufferedResponse in rust-http public.&lt;br /&gt;
&lt;br /&gt;
-Implement closing of connection along with on open and inclose events.&lt;br /&gt;
&lt;br /&gt;
-Implement sending of short simple strings which fit within a single frame.&lt;br /&gt;
&lt;br /&gt;
-Implement receiving of simple data and the on message event.&lt;br /&gt;
&lt;br /&gt;
-Implement sending of fragmented data.&lt;br /&gt;
&lt;br /&gt;
= Design Pattern =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91047</id>
		<title>CSC/ECE 517 Fall 2014/OSS M1451 ahs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91047"/>
		<updated>2014-10-30T00:51:32Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Future Goals for the Project */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://docs.google.com/a/ncsu.edu/document/d/18VECpUuVmEaC4Xew4EsIAmOsRKdIeXaTA42tLlNwIho/edit Project Topic Page]&lt;br /&gt;
==  Implement the WebSocket API ==&lt;br /&gt;
This wiki page contains details on the work done for the initial step of the task of [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Rust &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Rust_(programming_language)&amp;lt;/ref&amp;gt;==&lt;br /&gt;
Rust is a curly-brace, block-structured expression language.&lt;br /&gt;
&lt;br /&gt;
*It visually resembles the C language family, but differs significantly in syntactic and semantic details. &lt;br /&gt;
&lt;br /&gt;
*Its design is oriented toward concerns of “programming in the large”, that is, of creating and maintaining boundaries – both abstract and operational – that preserve large-system integrity, availability and concurrency.&lt;br /&gt;
&lt;br /&gt;
*It supports a mixture of imperative procedural, concurrent actor, object-oriented and pure functional styles. Rust also supports generic programming and &lt;br /&gt;
metaprogramming, in both static and dynamic styles.&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fn main() {&lt;br /&gt;
    println!(&amp;quot;hello, world&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Servo &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Servo_(layout_engine)&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
Servo is an experimental web browser layout engine being developed by Mozilla.&lt;br /&gt;
&lt;br /&gt;
*The prototype seeks to create a highly parallel environment, in which many components (such as rendering, layout, HTML parsing, image decoding, etc.) are &lt;br /&gt;
handled by fine-grained, isolated tasks. &lt;br /&gt;
&lt;br /&gt;
*The project has a symbiotic relationship with the Rust programming language, in which it is being developed.&lt;br /&gt;
&lt;br /&gt;
*Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a &lt;br /&gt;
solid, embedded engine. Although Servo is a research project, it is designed to be &amp;quot;productisable&amp;quot;—the code that we write should be of high enough quality that it could eventually be shipped to users.&lt;br /&gt;
&lt;br /&gt;
== Task Architecture Diagrams&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
=Implementation Steps=&lt;br /&gt;
We carried out the implementation for this project on a Mac machine. The steps we followed for the implementation are as follows:&lt;br /&gt;
&lt;br /&gt;
== Compiling Rust ==&lt;br /&gt;
1. The initial step to build Servo required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub using the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git://github.com/mozilla/rust.git&lt;br /&gt;
cd rust&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Use the following commands to build the Rust compiler:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
make check&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will build and test the compiler, standard libraries, and supporting tools.&lt;br /&gt;
&lt;br /&gt;
== Build Servo ==&lt;br /&gt;
1. Fork the servo repository and clone the source code into the local repository using the command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://github.com/servo/servo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Build servo using the following commands:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Part One Of the Project ==&lt;br /&gt;
&lt;br /&gt;
-Created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo. &lt;br /&gt;
&lt;br /&gt;
-We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project.&lt;br /&gt;
&lt;br /&gt;
-We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor. &lt;br /&gt;
&lt;br /&gt;
-We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
&lt;br /&gt;
-We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
&lt;br /&gt;
-After making all the changes we build are changes into servo.&lt;br /&gt;
&lt;br /&gt;
= Future Goals for the Project =&lt;br /&gt;
&lt;br /&gt;
-Create a basic connection to the server using the websocket connection protocol as specified in the [http://tools.ietf.org/html/rfc6455#section-4.1].&lt;br /&gt;
&lt;br /&gt;
-In order to allow writing more data to the existing socket connection, we plan to make the stream member in the BufferedResponse in rust-http public.&lt;br /&gt;
&lt;br /&gt;
-Implement closing of connection along with on open and inclose events.&lt;br /&gt;
&lt;br /&gt;
-Implement sending of short simple strings which fit within a single frame.&lt;br /&gt;
&lt;br /&gt;
-Implement receiving of simple data and the on message event.&lt;br /&gt;
&lt;br /&gt;
-Implement sending of fragmented data.&lt;br /&gt;
&lt;br /&gt;
= Design Pattern =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91046</id>
		<title>CSC/ECE 517 Fall 2014/OSS M1451 ahs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91046"/>
		<updated>2014-10-30T00:50:56Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Future Goals for the Project */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://docs.google.com/a/ncsu.edu/document/d/18VECpUuVmEaC4Xew4EsIAmOsRKdIeXaTA42tLlNwIho/edit Project Topic Page]&lt;br /&gt;
==  Implement the WebSocket API ==&lt;br /&gt;
This wiki page contains details on the work done for the initial step of the task of [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Rust &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Rust_(programming_language)&amp;lt;/ref&amp;gt;==&lt;br /&gt;
Rust is a curly-brace, block-structured expression language.&lt;br /&gt;
&lt;br /&gt;
*It visually resembles the C language family, but differs significantly in syntactic and semantic details. &lt;br /&gt;
&lt;br /&gt;
*Its design is oriented toward concerns of “programming in the large”, that is, of creating and maintaining boundaries – both abstract and operational – that preserve large-system integrity, availability and concurrency.&lt;br /&gt;
&lt;br /&gt;
*It supports a mixture of imperative procedural, concurrent actor, object-oriented and pure functional styles. Rust also supports generic programming and &lt;br /&gt;
metaprogramming, in both static and dynamic styles.&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fn main() {&lt;br /&gt;
    println!(&amp;quot;hello, world&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Servo &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Servo_(layout_engine)&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
Servo is an experimental web browser layout engine being developed by Mozilla.&lt;br /&gt;
&lt;br /&gt;
*The prototype seeks to create a highly parallel environment, in which many components (such as rendering, layout, HTML parsing, image decoding, etc.) are &lt;br /&gt;
handled by fine-grained, isolated tasks. &lt;br /&gt;
&lt;br /&gt;
*The project has a symbiotic relationship with the Rust programming language, in which it is being developed.&lt;br /&gt;
&lt;br /&gt;
*Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a &lt;br /&gt;
solid, embedded engine. Although Servo is a research project, it is designed to be &amp;quot;productisable&amp;quot;—the code that we write should be of high enough quality that it could eventually be shipped to users.&lt;br /&gt;
&lt;br /&gt;
== Task Architecture Diagrams&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
=Implementation Steps=&lt;br /&gt;
We carried out the implementation for this project on a Mac machine. The steps we followed for the implementation are as follows:&lt;br /&gt;
&lt;br /&gt;
== Compiling Rust ==&lt;br /&gt;
1. The initial step to build Servo required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub using the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git://github.com/mozilla/rust.git&lt;br /&gt;
cd rust&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Use the following commands to build the Rust compiler:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
make check&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will build and test the compiler, standard libraries, and supporting tools.&lt;br /&gt;
&lt;br /&gt;
== Build Servo ==&lt;br /&gt;
1. Fork the servo repository and clone the source code into the local repository using the command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://github.com/servo/servo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Build servo using the following commands:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Part One Of the Project ==&lt;br /&gt;
&lt;br /&gt;
-Created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo. &lt;br /&gt;
&lt;br /&gt;
-We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project.&lt;br /&gt;
&lt;br /&gt;
-We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor. &lt;br /&gt;
&lt;br /&gt;
-We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
&lt;br /&gt;
-We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
&lt;br /&gt;
-After making all the changes we build are changes into servo.&lt;br /&gt;
&lt;br /&gt;
= Future Goals for the Project =&lt;br /&gt;
&lt;br /&gt;
-Create a basic connection to the server using the websocket connection protocol [http://tools.ietf.org/html/rfc6455#section-4.1].&lt;br /&gt;
&lt;br /&gt;
-In order to allow writing more data to the existing socket connection, we plan to make the stream member in the BufferedResponse in rust-http public.&lt;br /&gt;
&lt;br /&gt;
-Implement closing of connection along with on open and inclose events.&lt;br /&gt;
&lt;br /&gt;
-Implement sending of short simple strings which fit within a single frame.&lt;br /&gt;
&lt;br /&gt;
-Implement receiving of simple data and the on message event.&lt;br /&gt;
&lt;br /&gt;
-Implement sending of fragmented data.&lt;br /&gt;
&lt;br /&gt;
= Design Pattern =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91045</id>
		<title>CSC/ECE 517 Fall 2014/OSS M1451 ahs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91045"/>
		<updated>2014-10-30T00:49:12Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /*  Part One Of the Project  */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://docs.google.com/a/ncsu.edu/document/d/18VECpUuVmEaC4Xew4EsIAmOsRKdIeXaTA42tLlNwIho/edit Project Topic Page]&lt;br /&gt;
==  Implement the WebSocket API ==&lt;br /&gt;
This wiki page contains details on the work done for the initial step of the task of [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Rust &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Rust_(programming_language)&amp;lt;/ref&amp;gt;==&lt;br /&gt;
Rust is a curly-brace, block-structured expression language.&lt;br /&gt;
&lt;br /&gt;
*It visually resembles the C language family, but differs significantly in syntactic and semantic details. &lt;br /&gt;
&lt;br /&gt;
*Its design is oriented toward concerns of “programming in the large”, that is, of creating and maintaining boundaries – both abstract and operational – that preserve large-system integrity, availability and concurrency.&lt;br /&gt;
&lt;br /&gt;
*It supports a mixture of imperative procedural, concurrent actor, object-oriented and pure functional styles. Rust also supports generic programming and &lt;br /&gt;
metaprogramming, in both static and dynamic styles.&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fn main() {&lt;br /&gt;
    println!(&amp;quot;hello, world&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Servo &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Servo_(layout_engine)&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
Servo is an experimental web browser layout engine being developed by Mozilla.&lt;br /&gt;
&lt;br /&gt;
*The prototype seeks to create a highly parallel environment, in which many components (such as rendering, layout, HTML parsing, image decoding, etc.) are &lt;br /&gt;
handled by fine-grained, isolated tasks. &lt;br /&gt;
&lt;br /&gt;
*The project has a symbiotic relationship with the Rust programming language, in which it is being developed.&lt;br /&gt;
&lt;br /&gt;
*Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a &lt;br /&gt;
solid, embedded engine. Although Servo is a research project, it is designed to be &amp;quot;productisable&amp;quot;—the code that we write should be of high enough quality that it could eventually be shipped to users.&lt;br /&gt;
&lt;br /&gt;
== Task Architecture Diagrams&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
=Implementation Steps=&lt;br /&gt;
We carried out the implementation for this project on a Mac machine. The steps we followed for the implementation are as follows:&lt;br /&gt;
&lt;br /&gt;
== Compiling Rust ==&lt;br /&gt;
1. The initial step to build Servo required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub using the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git://github.com/mozilla/rust.git&lt;br /&gt;
cd rust&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Use the following commands to build the Rust compiler:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
make check&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will build and test the compiler, standard libraries, and supporting tools.&lt;br /&gt;
&lt;br /&gt;
== Build Servo ==&lt;br /&gt;
1. Fork the servo repository and clone the source code into the local repository using the command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://github.com/servo/servo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Build servo using the following commands:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Part One Of the Project ==&lt;br /&gt;
&lt;br /&gt;
-Created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo. &lt;br /&gt;
&lt;br /&gt;
-We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project.&lt;br /&gt;
&lt;br /&gt;
-We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor. &lt;br /&gt;
&lt;br /&gt;
-We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
&lt;br /&gt;
-We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
&lt;br /&gt;
-After making all the changes we build are changes into servo.&lt;br /&gt;
&lt;br /&gt;
= Future Goals for the Project =&lt;br /&gt;
&lt;br /&gt;
-Create a basic connection to the server using the websocket connection protocol[http://tools.ietf.org/html/rfc6455#section-4.1].&lt;br /&gt;
&lt;br /&gt;
-In order to allow writing more data to the existing socket connection, we plan to make the stream member in the BufferedResponse in rust-http public.&lt;br /&gt;
&lt;br /&gt;
-Implement closing of connection along with on open and inclose events.&lt;br /&gt;
&lt;br /&gt;
-Implement sending of short simple strings which fit within a single frame.&lt;br /&gt;
&lt;br /&gt;
-Implement receiving of simple data and the on message event.&lt;br /&gt;
&lt;br /&gt;
-Implement sending of fragmented data.&lt;br /&gt;
&lt;br /&gt;
= Design Pattern =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91044</id>
		<title>CSC/ECE 517 Fall 2014/OSS M1451 ahs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91044"/>
		<updated>2014-10-30T00:48:55Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Build Servo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://docs.google.com/a/ncsu.edu/document/d/18VECpUuVmEaC4Xew4EsIAmOsRKdIeXaTA42tLlNwIho/edit Project Topic Page]&lt;br /&gt;
==  Implement the WebSocket API ==&lt;br /&gt;
This wiki page contains details on the work done for the initial step of the task of [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Rust &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Rust_(programming_language)&amp;lt;/ref&amp;gt;==&lt;br /&gt;
Rust is a curly-brace, block-structured expression language.&lt;br /&gt;
&lt;br /&gt;
*It visually resembles the C language family, but differs significantly in syntactic and semantic details. &lt;br /&gt;
&lt;br /&gt;
*Its design is oriented toward concerns of “programming in the large”, that is, of creating and maintaining boundaries – both abstract and operational – that preserve large-system integrity, availability and concurrency.&lt;br /&gt;
&lt;br /&gt;
*It supports a mixture of imperative procedural, concurrent actor, object-oriented and pure functional styles. Rust also supports generic programming and &lt;br /&gt;
metaprogramming, in both static and dynamic styles.&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fn main() {&lt;br /&gt;
    println!(&amp;quot;hello, world&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Servo &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Servo_(layout_engine)&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
Servo is an experimental web browser layout engine being developed by Mozilla.&lt;br /&gt;
&lt;br /&gt;
*The prototype seeks to create a highly parallel environment, in which many components (such as rendering, layout, HTML parsing, image decoding, etc.) are &lt;br /&gt;
handled by fine-grained, isolated tasks. &lt;br /&gt;
&lt;br /&gt;
*The project has a symbiotic relationship with the Rust programming language, in which it is being developed.&lt;br /&gt;
&lt;br /&gt;
*Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a &lt;br /&gt;
solid, embedded engine. Although Servo is a research project, it is designed to be &amp;quot;productisable&amp;quot;—the code that we write should be of high enough quality that it could eventually be shipped to users.&lt;br /&gt;
&lt;br /&gt;
== Task Architecture Diagrams&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
=Implementation Steps=&lt;br /&gt;
We carried out the implementation for this project on a Mac machine. The steps we followed for the implementation are as follows:&lt;br /&gt;
&lt;br /&gt;
== Compiling Rust ==&lt;br /&gt;
1. The initial step to build Servo required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub using the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git://github.com/mozilla/rust.git&lt;br /&gt;
cd rust&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Use the following commands to build the Rust compiler:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
make check&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will build and test the compiler, standard libraries, and supporting tools.&lt;br /&gt;
&lt;br /&gt;
== Build Servo ==&lt;br /&gt;
1. Fork the servo repository and clone the source code into the local repository using the command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://github.com/servo/servo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Build servo using the following commands:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;b&amp;gt; Part One Of the Project &amp;lt;/b&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
-Created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo. &lt;br /&gt;
&lt;br /&gt;
-We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project.&lt;br /&gt;
&lt;br /&gt;
-We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor. &lt;br /&gt;
&lt;br /&gt;
-We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
&lt;br /&gt;
-We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
&lt;br /&gt;
-After making all the changes we build are changes into servo.&lt;br /&gt;
&lt;br /&gt;
= Future Goals for the Project =&lt;br /&gt;
&lt;br /&gt;
-Create a basic connection to the server using the websocket connection protocol[http://tools.ietf.org/html/rfc6455#section-4.1].&lt;br /&gt;
&lt;br /&gt;
-In order to allow writing more data to the existing socket connection, we plan to make the stream member in the BufferedResponse in rust-http public.&lt;br /&gt;
&lt;br /&gt;
-Implement closing of connection along with on open and inclose events.&lt;br /&gt;
&lt;br /&gt;
-Implement sending of short simple strings which fit within a single frame.&lt;br /&gt;
&lt;br /&gt;
-Implement receiving of simple data and the on message event.&lt;br /&gt;
&lt;br /&gt;
-Implement sending of fragmented data.&lt;br /&gt;
&lt;br /&gt;
= Design Pattern =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91043</id>
		<title>CSC/ECE 517 Fall 2014/OSS M1451 ahs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91043"/>
		<updated>2014-10-30T00:48:40Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Compiling Rust */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://docs.google.com/a/ncsu.edu/document/d/18VECpUuVmEaC4Xew4EsIAmOsRKdIeXaTA42tLlNwIho/edit Project Topic Page]&lt;br /&gt;
==  Implement the WebSocket API ==&lt;br /&gt;
This wiki page contains details on the work done for the initial step of the task of [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Rust &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Rust_(programming_language)&amp;lt;/ref&amp;gt;==&lt;br /&gt;
Rust is a curly-brace, block-structured expression language.&lt;br /&gt;
&lt;br /&gt;
*It visually resembles the C language family, but differs significantly in syntactic and semantic details. &lt;br /&gt;
&lt;br /&gt;
*Its design is oriented toward concerns of “programming in the large”, that is, of creating and maintaining boundaries – both abstract and operational – that preserve large-system integrity, availability and concurrency.&lt;br /&gt;
&lt;br /&gt;
*It supports a mixture of imperative procedural, concurrent actor, object-oriented and pure functional styles. Rust also supports generic programming and &lt;br /&gt;
metaprogramming, in both static and dynamic styles.&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fn main() {&lt;br /&gt;
    println!(&amp;quot;hello, world&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Servo &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Servo_(layout_engine)&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
Servo is an experimental web browser layout engine being developed by Mozilla.&lt;br /&gt;
&lt;br /&gt;
*The prototype seeks to create a highly parallel environment, in which many components (such as rendering, layout, HTML parsing, image decoding, etc.) are &lt;br /&gt;
handled by fine-grained, isolated tasks. &lt;br /&gt;
&lt;br /&gt;
*The project has a symbiotic relationship with the Rust programming language, in which it is being developed.&lt;br /&gt;
&lt;br /&gt;
*Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a &lt;br /&gt;
solid, embedded engine. Although Servo is a research project, it is designed to be &amp;quot;productisable&amp;quot;—the code that we write should be of high enough quality that it could eventually be shipped to users.&lt;br /&gt;
&lt;br /&gt;
== Task Architecture Diagrams&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
=Implementation Steps=&lt;br /&gt;
We carried out the implementation for this project on a Mac machine. The steps we followed for the implementation are as follows:&lt;br /&gt;
&lt;br /&gt;
== Compiling Rust ==&lt;br /&gt;
1. The initial step to build Servo required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub using the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git://github.com/mozilla/rust.git&lt;br /&gt;
cd rust&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Use the following commands to build the Rust compiler:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
make check&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will build and test the compiler, standard libraries, and supporting tools.&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;b&amp;gt;Build Servo&amp;lt;/b&amp;gt;==&lt;br /&gt;
1. Fork the servo repository and clone the source code into the local repository using the command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://github.com/servo/servo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Build servo using the following commands:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;b&amp;gt; Part One Of the Project &amp;lt;/b&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
-Created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo. &lt;br /&gt;
&lt;br /&gt;
-We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project.&lt;br /&gt;
&lt;br /&gt;
-We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor. &lt;br /&gt;
&lt;br /&gt;
-We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
&lt;br /&gt;
-We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
&lt;br /&gt;
-After making all the changes we build are changes into servo.&lt;br /&gt;
&lt;br /&gt;
= Future Goals for the Project =&lt;br /&gt;
&lt;br /&gt;
-Create a basic connection to the server using the websocket connection protocol[http://tools.ietf.org/html/rfc6455#section-4.1].&lt;br /&gt;
&lt;br /&gt;
-In order to allow writing more data to the existing socket connection, we plan to make the stream member in the BufferedResponse in rust-http public.&lt;br /&gt;
&lt;br /&gt;
-Implement closing of connection along with on open and inclose events.&lt;br /&gt;
&lt;br /&gt;
-Implement sending of short simple strings which fit within a single frame.&lt;br /&gt;
&lt;br /&gt;
-Implement receiving of simple data and the on message event.&lt;br /&gt;
&lt;br /&gt;
-Implement sending of fragmented data.&lt;br /&gt;
&lt;br /&gt;
= Design Pattern =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91042</id>
		<title>CSC/ECE 517 Fall 2014/OSS M1451 ahs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91042"/>
		<updated>2014-10-30T00:48:01Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Future Goals for the Project */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://docs.google.com/a/ncsu.edu/document/d/18VECpUuVmEaC4Xew4EsIAmOsRKdIeXaTA42tLlNwIho/edit Project Topic Page]&lt;br /&gt;
==  Implement the WebSocket API ==&lt;br /&gt;
This wiki page contains details on the work done for the initial step of the task of [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Rust &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Rust_(programming_language)&amp;lt;/ref&amp;gt;==&lt;br /&gt;
Rust is a curly-brace, block-structured expression language.&lt;br /&gt;
&lt;br /&gt;
*It visually resembles the C language family, but differs significantly in syntactic and semantic details. &lt;br /&gt;
&lt;br /&gt;
*Its design is oriented toward concerns of “programming in the large”, that is, of creating and maintaining boundaries – both abstract and operational – that preserve large-system integrity, availability and concurrency.&lt;br /&gt;
&lt;br /&gt;
*It supports a mixture of imperative procedural, concurrent actor, object-oriented and pure functional styles. Rust also supports generic programming and &lt;br /&gt;
metaprogramming, in both static and dynamic styles.&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fn main() {&lt;br /&gt;
    println!(&amp;quot;hello, world&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Servo &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Servo_(layout_engine)&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
Servo is an experimental web browser layout engine being developed by Mozilla.&lt;br /&gt;
&lt;br /&gt;
*The prototype seeks to create a highly parallel environment, in which many components (such as rendering, layout, HTML parsing, image decoding, etc.) are &lt;br /&gt;
handled by fine-grained, isolated tasks. &lt;br /&gt;
&lt;br /&gt;
*The project has a symbiotic relationship with the Rust programming language, in which it is being developed.&lt;br /&gt;
&lt;br /&gt;
*Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a &lt;br /&gt;
solid, embedded engine. Although Servo is a research project, it is designed to be &amp;quot;productisable&amp;quot;—the code that we write should be of high enough quality that it could eventually be shipped to users.&lt;br /&gt;
&lt;br /&gt;
== Task Architecture Diagrams&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
=Implementation Steps=&lt;br /&gt;
We carried out the implementation for this project on a Mac machine. The steps we followed for the implementation are as follows:&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;b&amp;gt;Compiling Rust&amp;lt;/b&amp;gt;==&lt;br /&gt;
1. The initial step to build Servo required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub using the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git://github.com/mozilla/rust.git&lt;br /&gt;
cd rust&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Use the following commands to build the Rust compiler:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
make check&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will build and test the compiler, standard libraries, and supporting tools.&lt;br /&gt;
==&amp;lt;b&amp;gt;Build Servo&amp;lt;/b&amp;gt;==&lt;br /&gt;
1. Fork the servo repository and clone the source code into the local repository using the command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://github.com/servo/servo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Build servo using the following commands:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;b&amp;gt; Part One Of the Project &amp;lt;/b&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
-Created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo. &lt;br /&gt;
&lt;br /&gt;
-We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project.&lt;br /&gt;
&lt;br /&gt;
-We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor. &lt;br /&gt;
&lt;br /&gt;
-We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
&lt;br /&gt;
-We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
&lt;br /&gt;
-After making all the changes we build are changes into servo.&lt;br /&gt;
&lt;br /&gt;
= Future Goals for the Project =&lt;br /&gt;
&lt;br /&gt;
-Create a basic connection to the server using the websocket connection protocol[http://tools.ietf.org/html/rfc6455#section-4.1].&lt;br /&gt;
&lt;br /&gt;
-In order to allow writing more data to the existing socket connection, we plan to make the stream member in the BufferedResponse in rust-http public.&lt;br /&gt;
&lt;br /&gt;
-Implement closing of connection along with on open and inclose events.&lt;br /&gt;
&lt;br /&gt;
-Implement sending of short simple strings which fit within a single frame.&lt;br /&gt;
&lt;br /&gt;
-Implement receiving of simple data and the on message event.&lt;br /&gt;
&lt;br /&gt;
-Implement sending of fragmented data.&lt;br /&gt;
&lt;br /&gt;
= Design Pattern =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91041</id>
		<title>CSC/ECE 517 Fall 2014/OSS M1451 ahs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91041"/>
		<updated>2014-10-30T00:47:26Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://docs.google.com/a/ncsu.edu/document/d/18VECpUuVmEaC4Xew4EsIAmOsRKdIeXaTA42tLlNwIho/edit Project Topic Page]&lt;br /&gt;
==  Implement the WebSocket API ==&lt;br /&gt;
This wiki page contains details on the work done for the initial step of the task of [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Rust &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Rust_(programming_language)&amp;lt;/ref&amp;gt;==&lt;br /&gt;
Rust is a curly-brace, block-structured expression language.&lt;br /&gt;
&lt;br /&gt;
*It visually resembles the C language family, but differs significantly in syntactic and semantic details. &lt;br /&gt;
&lt;br /&gt;
*Its design is oriented toward concerns of “programming in the large”, that is, of creating and maintaining boundaries – both abstract and operational – that preserve large-system integrity, availability and concurrency.&lt;br /&gt;
&lt;br /&gt;
*It supports a mixture of imperative procedural, concurrent actor, object-oriented and pure functional styles. Rust also supports generic programming and &lt;br /&gt;
metaprogramming, in both static and dynamic styles.&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fn main() {&lt;br /&gt;
    println!(&amp;quot;hello, world&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Servo &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Servo_(layout_engine)&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
Servo is an experimental web browser layout engine being developed by Mozilla.&lt;br /&gt;
&lt;br /&gt;
*The prototype seeks to create a highly parallel environment, in which many components (such as rendering, layout, HTML parsing, image decoding, etc.) are &lt;br /&gt;
handled by fine-grained, isolated tasks. &lt;br /&gt;
&lt;br /&gt;
*The project has a symbiotic relationship with the Rust programming language, in which it is being developed.&lt;br /&gt;
&lt;br /&gt;
*Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a &lt;br /&gt;
solid, embedded engine. Although Servo is a research project, it is designed to be &amp;quot;productisable&amp;quot;—the code that we write should be of high enough quality that it could eventually be shipped to users.&lt;br /&gt;
&lt;br /&gt;
== Task Architecture Diagrams&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
=Implementation Steps=&lt;br /&gt;
We carried out the implementation for this project on a Mac machine. The steps we followed for the implementation are as follows:&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;b&amp;gt;Compiling Rust&amp;lt;/b&amp;gt;==&lt;br /&gt;
1. The initial step to build Servo required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub using the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git://github.com/mozilla/rust.git&lt;br /&gt;
cd rust&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Use the following commands to build the Rust compiler:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
make check&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will build and test the compiler, standard libraries, and supporting tools.&lt;br /&gt;
==&amp;lt;b&amp;gt;Build Servo&amp;lt;/b&amp;gt;==&lt;br /&gt;
1. Fork the servo repository and clone the source code into the local repository using the command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://github.com/servo/servo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Build servo using the following commands:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;b&amp;gt; Part One Of the Project &amp;lt;/b&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
-Created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo. &lt;br /&gt;
&lt;br /&gt;
-We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project.&lt;br /&gt;
&lt;br /&gt;
-We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor. &lt;br /&gt;
&lt;br /&gt;
-We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
&lt;br /&gt;
-We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
&lt;br /&gt;
-After making all the changes we build are changes into servo.&lt;br /&gt;
&lt;br /&gt;
= Future Goals for the Project =&lt;br /&gt;
&lt;br /&gt;
-Create a basic connection to the server using the websocket connection protocol[http://tools.ietf.org/html/rfc6455#section-4.1]&lt;br /&gt;
-In order to allow writing more data to the existing socket connection, we plan to make the stream member in the BufferedResponse in rust-http public.&lt;br /&gt;
-Implement closing of connection along with on open and inclose events.&lt;br /&gt;
-Implement sending of short simple strings which fit within a single frame.&lt;br /&gt;
-Implement receiving of simple data and the on message event.&lt;br /&gt;
-Implement sending of fragmented data.&lt;br /&gt;
&lt;br /&gt;
= Design Pattern =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91040</id>
		<title>CSC/ECE 517 Fall 2014/OSS M1451 ahs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91040"/>
		<updated>2014-10-30T00:34:31Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /*  Part One Of the Project  */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://docs.google.com/a/ncsu.edu/document/d/18VECpUuVmEaC4Xew4EsIAmOsRKdIeXaTA42tLlNwIho/edit Project Topic Page]&lt;br /&gt;
==  Implement the WebSocket API ==&lt;br /&gt;
This wiki page contains details on the work done for the initial step of the task of [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Rust &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Rust_(programming_language)&amp;lt;/ref&amp;gt;==&lt;br /&gt;
Rust is a curly-brace, block-structured expression language.&lt;br /&gt;
&lt;br /&gt;
*It visually resembles the C language family, but differs significantly in syntactic and semantic details. &lt;br /&gt;
&lt;br /&gt;
*Its design is oriented toward concerns of “programming in the large”, that is, of creating and maintaining boundaries – both abstract and operational – that preserve large-system integrity, availability and concurrency.&lt;br /&gt;
&lt;br /&gt;
*It supports a mixture of imperative procedural, concurrent actor, object-oriented and pure functional styles. Rust also supports generic programming and &lt;br /&gt;
metaprogramming, in both static and dynamic styles.&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fn main() {&lt;br /&gt;
    println!(&amp;quot;hello, world&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Servo &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Servo_(layout_engine)&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
Servo is an experimental web browser layout engine being developed by Mozilla.&lt;br /&gt;
&lt;br /&gt;
*The prototype seeks to create a highly parallel environment, in which many components (such as rendering, layout, HTML parsing, image decoding, etc.) are &lt;br /&gt;
handled by fine-grained, isolated tasks. &lt;br /&gt;
&lt;br /&gt;
*The project has a symbiotic relationship with the Rust programming language, in which it is being developed.&lt;br /&gt;
&lt;br /&gt;
*Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a &lt;br /&gt;
solid, embedded engine. Although Servo is a research project, it is designed to be &amp;quot;productisable&amp;quot;—the code that we write should be of high enough quality that it could eventually be shipped to users.&lt;br /&gt;
&lt;br /&gt;
== Task Architecture Diagrams&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
=Implementation Steps=&lt;br /&gt;
We carried out the implementation for this project on a Mac machine. The steps we followed for the implementation are as follows:&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;b&amp;gt;Compiling Rust&amp;lt;/b&amp;gt;==&lt;br /&gt;
1. The initial step to build Servo required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub using the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git://github.com/mozilla/rust.git&lt;br /&gt;
cd rust&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Use the following commands to build the Rust compiler:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
make check&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will build and test the compiler, standard libraries, and supporting tools.&lt;br /&gt;
==&amp;lt;b&amp;gt;Build Servo&amp;lt;/b&amp;gt;==&lt;br /&gt;
1. Fork the servo repository and clone the source code into the local repository using the command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://github.com/servo/servo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Build servo using the following commands:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;b&amp;gt; Part One Of the Project &amp;lt;/b&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
-Created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo. &lt;br /&gt;
&lt;br /&gt;
-We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project.&lt;br /&gt;
&lt;br /&gt;
-We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor. &lt;br /&gt;
&lt;br /&gt;
-We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
&lt;br /&gt;
-We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
&lt;br /&gt;
-After making all the changes we build are changes into servo.&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91039</id>
		<title>CSC/ECE 517 Fall 2014/OSS M1451 ahs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91039"/>
		<updated>2014-10-30T00:33:36Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Implementation Steps */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://docs.google.com/a/ncsu.edu/document/d/18VECpUuVmEaC4Xew4EsIAmOsRKdIeXaTA42tLlNwIho/edit Project Topic Page]&lt;br /&gt;
==  Implement the WebSocket API ==&lt;br /&gt;
This wiki page contains details on the work done for the initial step of the task of [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Rust &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Rust_(programming_language)&amp;lt;/ref&amp;gt;==&lt;br /&gt;
Rust is a curly-brace, block-structured expression language.&lt;br /&gt;
&lt;br /&gt;
*It visually resembles the C language family, but differs significantly in syntactic and semantic details. &lt;br /&gt;
&lt;br /&gt;
*Its design is oriented toward concerns of “programming in the large”, that is, of creating and maintaining boundaries – both abstract and operational – that preserve large-system integrity, availability and concurrency.&lt;br /&gt;
&lt;br /&gt;
*It supports a mixture of imperative procedural, concurrent actor, object-oriented and pure functional styles. Rust also supports generic programming and &lt;br /&gt;
metaprogramming, in both static and dynamic styles.&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fn main() {&lt;br /&gt;
    println!(&amp;quot;hello, world&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Servo &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Servo_(layout_engine)&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
Servo is an experimental web browser layout engine being developed by Mozilla.&lt;br /&gt;
&lt;br /&gt;
*The prototype seeks to create a highly parallel environment, in which many components (such as rendering, layout, HTML parsing, image decoding, etc.) are &lt;br /&gt;
handled by fine-grained, isolated tasks. &lt;br /&gt;
&lt;br /&gt;
*The project has a symbiotic relationship with the Rust programming language, in which it is being developed.&lt;br /&gt;
&lt;br /&gt;
*Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a &lt;br /&gt;
solid, embedded engine. Although Servo is a research project, it is designed to be &amp;quot;productisable&amp;quot;—the code that we write should be of high enough quality that it could eventually be shipped to users.&lt;br /&gt;
&lt;br /&gt;
== Task Architecture Diagrams&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
=Implementation Steps=&lt;br /&gt;
We carried out the implementation for this project on a Mac machine. The steps we followed for the implementation are as follows:&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;b&amp;gt;Compiling Rust&amp;lt;/b&amp;gt;==&lt;br /&gt;
1. The initial step to build Servo required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub using the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git://github.com/mozilla/rust.git&lt;br /&gt;
cd rust&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Use the following commands to build the Rust compiler:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
make check&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will build and test the compiler, standard libraries, and supporting tools.&lt;br /&gt;
==&amp;lt;b&amp;gt;Build Servo&amp;lt;/b&amp;gt;==&lt;br /&gt;
1. Fork the servo repository and clone the source code into the local repository using the command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://github.com/servo/servo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Build servo using the following commands:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;b&amp;gt; Part One Of the Project &amp;lt;b&amp;gt; ==&lt;br /&gt;
-Created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket. This interface is inherited from the EventTarget interface in servo. &lt;br /&gt;
-We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project.&lt;br /&gt;
-We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor. &lt;br /&gt;
-We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
-We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
-After making all the changes we build are changes into servo.&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91022</id>
		<title>CSC/ECE 517 Fall 2014/OSS M1451 ahs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91022"/>
		<updated>2014-10-30T00:19:59Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://docs.google.com/a/ncsu.edu/document/d/18VECpUuVmEaC4Xew4EsIAmOsRKdIeXaTA42tLlNwIho/edit Project Topic Page]&lt;br /&gt;
==  Implement the WebSocket API ==&lt;br /&gt;
This wiki page contains details on the work done for the initial step of the task of [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Rust &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Rust_(programming_language)&amp;lt;/ref&amp;gt;==&lt;br /&gt;
Rust is a curly-brace, block-structured expression language.&lt;br /&gt;
&lt;br /&gt;
*It visually resembles the C language family, but differs significantly in syntactic and semantic details. &lt;br /&gt;
&lt;br /&gt;
*Its design is oriented toward concerns of “programming in the large”, that is, of creating and maintaining boundaries – both abstract and operational – that preserve large-system integrity, availability and concurrency.&lt;br /&gt;
&lt;br /&gt;
*It supports a mixture of imperative procedural, concurrent actor, object-oriented and pure functional styles. Rust also supports generic programming and &lt;br /&gt;
metaprogramming, in both static and dynamic styles.&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fn main() {&lt;br /&gt;
    println!(&amp;quot;hello, world&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Servo &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Servo_(layout_engine)&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
Servo is an experimental web browser layout engine being developed by Mozilla.&lt;br /&gt;
&lt;br /&gt;
*The prototype seeks to create a highly parallel environment, in which many components (such as rendering, layout, HTML parsing, image decoding, etc.) are &lt;br /&gt;
handled by fine-grained, isolated tasks. &lt;br /&gt;
&lt;br /&gt;
*The project has a symbiotic relationship with the Rust programming language, in which it is being developed.&lt;br /&gt;
&lt;br /&gt;
*Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a &lt;br /&gt;
solid, embedded engine. Although Servo is a research project, it is designed to be &amp;quot;productisable&amp;quot;—the code that we write should be of high enough quality that it could eventually be shipped to users.&lt;br /&gt;
&lt;br /&gt;
== Task Architecture Diagrams&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
=Implementation Steps=&lt;br /&gt;
We carried out the implementation for this project on a Mac machine. The steps we followed for the implementation are as follows:&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;b&amp;gt;Compiling Rust&amp;lt;/b&amp;gt;==&lt;br /&gt;
1. The initial step to build Servo required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub using the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git://github.com/mozilla/rust.git&lt;br /&gt;
cd rust&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Use the following commands to build the Rust compiler:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
make check&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will build and test the compiler, standard libraries, and supporting tools.&lt;br /&gt;
==&amp;lt;b&amp;gt;Build Servo&amp;lt;/b&amp;gt;==&lt;br /&gt;
1. Fork the servo repository and clone the source code into the local repository using the command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://github.com/servo/servo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Build servo using the following commands:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91021</id>
		<title>CSC/ECE 517 Fall 2014/OSS M1451 ahs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_M1451_ahs&amp;diff=91021"/>
		<updated>2014-10-30T00:18:25Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://docs.google.com/a/ncsu.edu/document/d/18VECpUuVmEaC4Xew4EsIAmOsRKdIeXaTA42tLlNwIho/edit Project Topic Page]&lt;br /&gt;
==  Implement the WebSocket API ==&lt;br /&gt;
This wiki page contains details on the work done for the initial step of the task of [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Rust &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Rust_(programming_language)&amp;lt;/ref&amp;gt;==&lt;br /&gt;
Rust is a curly-brace, block-structured expression language.&lt;br /&gt;
&lt;br /&gt;
*It visually resembles the C language family, but differs significantly in syntactic and semantic details. &lt;br /&gt;
&lt;br /&gt;
*Its design is oriented toward concerns of “programming in the large”, that is, of creating and maintaining boundaries – both abstract and operational – that preserve large-system integrity, availability and concurrency.&lt;br /&gt;
&lt;br /&gt;
*It supports a mixture of imperative procedural, concurrent actor, object-oriented and pure functional styles. Rust also supports generic programming and &lt;br /&gt;
metaprogramming, in both static and dynamic styles.&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fn main() {&lt;br /&gt;
    println!(&amp;quot;hello, world&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Servo &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Servo_(layout_engine)&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
Servo is an experimental web browser layout engine being developed by Mozilla.&lt;br /&gt;
&lt;br /&gt;
*The prototype seeks to create a highly parallel environment, in which many components (such as rendering, layout, HTML parsing, image decoding, etc.) are &lt;br /&gt;
handled by fine-grained, isolated tasks. &lt;br /&gt;
&lt;br /&gt;
*The project has a symbiotic relationship with the Rust programming language, in which it is being developed.&lt;br /&gt;
&lt;br /&gt;
*Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a &lt;br /&gt;
solid, embedded engine. Although Servo is a research project, it is designed to be &amp;quot;productisable&amp;quot;—the code that we write should be of high enough quality that it could eventually be shipped to users.&lt;br /&gt;
&lt;br /&gt;
== Task Architecture Diagrams ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
=Implementation Steps=&lt;br /&gt;
We carried out the implementation for this project on a Mac machine. The steps we followed for the implementation are as follows:&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;b&amp;gt;Compiling Rust&amp;lt;/b&amp;gt;==&lt;br /&gt;
1. The initial step to build Servo required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub using the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone git://github.com/mozilla/rust.git&lt;br /&gt;
cd rust&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Use the following commands to build the Rust compiler:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
make check&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will build and test the compiler, standard libraries, and supporting tools.&lt;br /&gt;
==&amp;lt;b&amp;gt;Build Servo&amp;lt;/b&amp;gt;==&lt;br /&gt;
1. Fork the servo repository and clone the source code into the local repository using the command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://github.com/servo/servo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Build servo using the following commands:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:TaskCommunication.png&amp;diff=91017</id>
		<title>File:TaskCommunication.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:TaskCommunication.png&amp;diff=91017"/>
		<updated>2014-10-30T00:15:43Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:TaskSupervision.png&amp;diff=91016</id>
		<title>File:TaskSupervision.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:TaskSupervision.png&amp;diff=91016"/>
		<updated>2014-10-30T00:15:30Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=88599</id>
		<title>CSC/ECE 517 Fall 2014/ch1a 10 hu</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=88599"/>
		<updated>2014-09-26T01:25:19Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Additional References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==''' Go Programming Language''' ==&lt;br /&gt;
'''Go''', also commonly referred to as '''golang''', is a compiled, concurrent, garbage-collected, statically typed language developed at [http://en.wikipedia.org/wiki/Google Google]. It was developed by [http://en.wikipedia.org/wiki/Robert_Griesemer Robert Griesemer], [http://en.wikipedia.org/wiki/Rob_Pike Rob Pike] and [http://en.wikipedia.org/wiki/Ken_Thompson Ken Thompson] in 2007. It was announced in November 2009 and is currently being used in many production systems at Google. It is an open source project. The syntax is loosely derived from that of [http://en.wikipedia.org/wiki/C_(programming_language) C programming language], adding [http://en.wikipedia.org/wiki/Garbage_collection_(computer_science) garbage collection], type safety, some dynamic-typing capabilities. Additional built-in types such as variable-length arrays and key-value maps, and a large standard library are also supported. Different operating systems like Linux, Microsoft Windows, Mac OS X are suported by [https://golang.org/cmd/gc Gc] compiler of Go.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
&lt;br /&gt;
Go programming started of as a research project by Robert Griesemer, Rob Pike and Ken Thompson. They felt that there was no new system focused programming language that has come up in the last decade till 2008, while there were other developments like increase in the size of libraries, dominance of networking , client server focus, multi-core CPUs.&amp;lt;ref name = &amp;quot;Background 1&amp;quot;&amp;gt;[https://www.youtube.com/watch?v=rKnDgT73v8s Go Language Introduction speech]&amp;lt;/ref&amp;gt; So they wanted to come up with a new systems focused programming language that would address the above issues.&amp;lt;ref name=&amp;quot;BG2&amp;quot;&amp;gt;[http://techcrunch.com/2009/11/10/google-go-language TechCrunch]&amp;lt;/ref&amp;gt; They started sketching the goals for a new language on the white board on September 21, 2007. Within a few days the goals had settled into a plan to do something and a fair idea of what it would be. Design continued part-time in parallel with unrelated work.&lt;br /&gt;
By January 2008, Ken had started work on a compiler with which to explore ideas; it generated C code as its output. By mid-year the language had become a full-time project and had settled enough to attempt a production compiler. In May 2008, [http://research.google.com/pubs/author37504.html Ian Taylor] independently started on a [http://en.wikipedia.org/wiki/GNU_Compiler_Collection GCC] front end for Go using the draft specification.  [http://russ.cox.usesthis.com/ Russ Cox] joined in late 2008 and helped move the language and libraries from prototype to reality.&lt;br /&gt;
Go became a public [http://en.wikipedia.org/wiki/Open_source open source project] on November 10, 2009. Many people from the community have contributed ideas, discussions, and code.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Compilers and Runtime support=&lt;br /&gt;
&lt;br /&gt;
There are two Go compiler implementations, [https://golang.org/cmd/gc Gc] (the 6g program and friends) and [http://blog.golang.org/gccgo-in-gcc-471 gccgo ]. Gc uses a different calling convention and linker. It can therefore only be linked with C programs using the same convention. Gccgo is a GCC front-end that can be linked with GCC-compiled C or C++ programs.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cgo program provides the mechanism for a “foreign function interface” to allow safe calling of C libraries from Go code. [http://en.wikipedia.org/wiki/SWIG SWIG] extends this capability to C++ libraries. &lt;br /&gt;
&lt;br /&gt;
Again due to bootstrapping issues, the run-time code is mostly in C (with a tiny bit of assembler) although Go is capable of implementing most of it now. Gccgo's run-time support uses glibc. Gc uses a custom library to keep the footprint under control; it is compiled with a version of the [http://plan9.bell-labs.com/sys/doc/compiler.html Plan 9 C compiler] that supports resizable stacks for goroutines. The gccgo compiler implements these on Linux only, using a technique called segmented stacks, supported by recent modifications to the gold linker.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find all resources needed to compile and run Go Language here http://go-lang.cat-v.org/&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
 &lt;br /&gt;
Programming today involves too much bookkeeping, repetition, and clerical work. As Dick Gabriel says, “Old programs read like quiet conversations between a well-spoken research worker and a well-studied mechanical colleague, not as a debate with a compiler. Who'd have guessed sophistication bought such noise?” The sophistication is worthwhile—no one wants to go back to the old languages—but can it be more quietly achieved?&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Go attempts to reduce the amount of typing in both senses of the word. Throughout its design, &lt;br /&gt;
*They have tried to reduce clutter and complexity. &lt;br /&gt;
*There are no forward declarations and no header files. everything is declared exactly once. &lt;br /&gt;
*Initialization is expressive, automatic, and easy to use. &lt;br /&gt;
*Syntax is clean and light on keywords. Stuttering (foo.Foo* myFoo = new(foo.Foo)) is reduced by simple type derivation using the := declare-and-initialize construct. &lt;br /&gt;
*And perhaps most radically, there is no type hierarchy. They don't have to announce their relationships.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
These simplifications allow Go to be expressive yet comprehensible without sacrificing, well, sophistication.&lt;br /&gt;
Another important principle is to keep the concepts orthogonal. Methods can be implemented for any type; structures represent data while interfaces represent abstraction; and so on. Orthogonality makes it easier to understand what happens when things combine.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Comparison between Go Programming and C++ Programming language &amp;lt;ref name=&amp;quot;KTH&amp;quot;&amp;gt;[http://www.csc.kth.se/utbildning/kth/kurser/DD143X/dkand11/Group9Alexander/Joakim_Anneback_Johan_Stjernberg.finalreport.2.pdf KTH comparison]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;quora&amp;quot;&amp;gt;[http://www.quora.com/How-does-Go-compare-to-C++-and-Java Quora comparison]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;Scriptol&amp;quot;&amp;gt;[http://www.scriptol.com/programming/go.php scriptol]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
Go programming language was developed to run as fast as C++ programs while adding a lot of other modern day features. Some of the key differeneces are listed below&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;2&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Points of Comparison&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Go Programming Language&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | C++ Programming Language&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Primary Focus'''&lt;br /&gt;
|| Go focuses on garbage collection, concurrency and compiling quickly&lt;br /&gt;
|| C++ focuses on inheritance, generic types and pointer arithmetics.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Variable Sizes'''&lt;br /&gt;
|| Machine-independent types are now included without an import needed:  int8, int16, int32, int64, uint8, etc.&lt;br /&gt;
|| Machine-dependent variable sizes&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Class Hierarchies'''&lt;br /&gt;
|| Inheritance is not supported , but with the traditional structures with plain old functions and namespaces, is a MUCH &lt;br /&gt;
better, more flexible approach that leads to better, more maintainable code. &lt;br /&gt;
|| Inheritance is supported but it has its own share of problems like diamond inheritance, virtual inheritance and normal inheritance.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Function overloading'''&lt;br /&gt;
|| Not present in Go because it simplifies dispatch.	&lt;br /&gt;
|| Present in C++.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Genrics'''&lt;br /&gt;
|| Go does not currently support generic types. However, it does support objects without a type using the empty interface.&lt;br /&gt;
|| C++ on the other hand has support for generic types. Generic programming is supported by the use of function templates, class templates and, in some cases, specialized templates in C++.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Multithreading'''&lt;br /&gt;
|| Goroutines are Go's model of threads/coroutines. Each new goroutine runs in parallel with the current computation, in &amp;quot;the same address space. Goroutines are cheap and developers need not to &lt;br /&gt;
worry about the stack size.&lt;br /&gt;
|| In contrast, there is currently no built-in way to manage threads in C++, although the feature is expected in the upcoming new standard and is already today possible using third-party libraries. &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Garbage Collection'''&lt;br /&gt;
|| Go uses garbage collection for memory management, which means that if frees the programmer completely from keeping a track on the memory used.&lt;br /&gt;
|| C++ does not have any garbage collection and hence relies heavily on that the programmer knows what he or she is doing.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Language Design&amp;lt;ref name = &amp;quot;GoLang Book&amp;quot;&amp;gt;[http://www.golang-book.com, GoLang Book]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 package main //line 1&lt;br /&gt;
&lt;br /&gt;
   import “fmt”  //line 2&lt;br /&gt;
&lt;br /&gt;
   func main() {  //line 3&lt;br /&gt;
&lt;br /&gt;
       fmt.Println(“Hello World”) //line 4&lt;br /&gt;
&lt;br /&gt;
   } //line 5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The program above depicts the basic syntax of a program written using Go. Line1 specifies package declaration. Package is used to organize and reuse code. Line 2 is used for including the package “fmt” which is used for formatting input and output. Line 3 to 5 defines the function main. main is the function which is called when a program is executed. Println function in fmt is used to display content to the console i.e in this example Hello World is displayed in the console on executing the program.&lt;br /&gt;
&lt;br /&gt;
==Code Conventions and Style==&lt;br /&gt;
&lt;br /&gt;
* Go fmt tool is used to automatically standardize indentation, spaces and surface-level code details (go vet and go link perform checking automatically).&lt;br /&gt;
* Using tools and libraries provided in Go, there are standard approaches for API documentation (go doc), testing (go test), building( go build) and package management(go get).&lt;br /&gt;
* Syntax prevents any kind of cyclic dependencies.&lt;br /&gt;
* Unused variables and imports are not allowed.&lt;br /&gt;
* Elimination of functional programming constructs (such as map and try/finally) ensure a concrete and explicit programming style.&lt;br /&gt;
&lt;br /&gt;
==Types==&lt;br /&gt;
&lt;br /&gt;
* Numbers are represented in Go as either Integers or Floating point numbers.&lt;br /&gt;
**Integers: Used to represent numbers without a decimal component. Different integers supported by Go are: uint8, uint16, uint32, uint64, int8, int16, int32, int64. Uint is used for unsigned integers and int for signed. 8,16, 32, 64 indicate the number of bits each type would use.&lt;br /&gt;
**Floating Point Integers: Used to support decimal components. Go supports float32 and float64 to represent floating point numbers and complex32 and complex64 to represent complex numbers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var x int32 =4&lt;br /&gt;
var y float32 = 4.5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* String: String literals can be created using either double quotes(“Hello”) or back ticks(`Hello`). Strings have several operations associated them, for example one can find the length of the string or get a character at a specific index in a string. Example below illustrates these functions.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
	fmt.Println(len(“Hello”)) // output: 5&lt;br /&gt;
	fmt.Println(“Hello”[1]) // output: e&lt;br /&gt;
	fmt.Println(“Hello “+”Tom”) //output: Hello Tom&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Boolean: A 1 bit value is used to represent true or false.&lt;br /&gt;
&lt;br /&gt;
==Variables and Constants==&lt;br /&gt;
*Variabes in Go are indicated using the var keyword. Example: var x string=”hello” . They can also be shorthanded as x:=”hello” .&lt;br /&gt;
*The variable names should begin with a letter and can contain letters, digits or underscore character.&lt;br /&gt;
*The scope of the variable is the block in which it is defined and an attempt to access it outside the block would result in an error on running the program.&lt;br /&gt;
*Go provides support for constants (i.e. variables whose value can not be changed), using the const keyword. Example: const temp string = “Hello”&lt;br /&gt;
*In Go one can define multiple variables(or constants) using the following syntax:&lt;br /&gt;
    var(&lt;br /&gt;
         t1 =1&lt;br /&gt;
         t2=2&lt;br /&gt;
         t3=3&lt;br /&gt;
        t4=4&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Control Structures==&lt;br /&gt;
*For: It is used for repeating a list of statement(s) multiple times. The example below is used for calculating sum of numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    i := 1&lt;br /&gt;
    sum := 0&lt;br /&gt;
&lt;br /&gt;
    for i &amp;lt;= 10 {&lt;br /&gt;
        sum = sum + i&lt;br /&gt;
        i = i + 1&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    fmt.Println(“Sum:” + sum)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the example above i is a loop counter variable and is used to ensure that sum of numbers from 1 to 10 is computed. It indicates the number of times the statements inside the for loop are to be executed. The statement following the keyword for should evaluate to either true or false. If it is evaluated to true the body of for is executed, else we come out of the for loop.&lt;br /&gt;
&lt;br /&gt;
*If: Used to execute a block of statement(s) based on the evaluation of an expression to either true or false. It can also have an else associated with it.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    if i % 2 == 0 {&lt;br /&gt;
        fmt.Println(i + ” is divisble by 2”)&lt;br /&gt;
    } else {&lt;br /&gt;
        fmt.Println(i + “is not divisible by 2”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Switch: The value of the expression following switch is evaluated and is compared against the different cases. Based on the matching case, the block following that case is executed. Switch also has a default case in situations when none of the cases are matching.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    // if op ==1 then so a+b&lt;br /&gt;
    // if op == 2 then do a-b&lt;br /&gt;
    // if op == 3 then do a*b&lt;br /&gt;
    // if op ==4 then do a/b&lt;br /&gt;
    // default print, invalid operator&lt;br /&gt;
&lt;br /&gt;
    op:= 1&lt;br /&gt;
    a=6&lt;br /&gt;
    b=7&lt;br /&gt;
    switch(op) {&lt;br /&gt;
        case 1: fmt.Println(a+b)&lt;br /&gt;
        case 2: fmt.Println(a-b)&lt;br /&gt;
        case 3: fmt.Println(a*b)&lt;br /&gt;
        case 4: fmt.Println(a/b)&lt;br /&gt;
        default: fmt.Println(“Invalid Operator”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Arrays, Slices and Maps==&lt;br /&gt;
&lt;br /&gt;
*Arrays: Numbered sequence of elements starting with index zero and each of the elements having a fixed length. The example below illustrates various operations performed on arrays in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
    var x[10] int&lt;br /&gt;
    x[99]=100&lt;br /&gt;
    fmt.Println(x)  //[0 0 ….. 0 100]&lt;br /&gt;
    fmt.Println(len(x)) //100&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Slices: &lt;br /&gt;
** It is a segment of an array.&lt;br /&gt;
** They have a length and are indexable.&lt;br /&gt;
**In case of a slice the size does not have to specified in the square bracket.&lt;br /&gt;
**Slices support two in-build functions: copy and append.&lt;br /&gt;
**The program below illustrates the different ways to create slices and use of copy and append.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    arr := [10] int {1,2,3,4,5,6,7,8,9,10}&lt;br /&gt;
    x := make([]int,10) // creates a slice [1...10]&lt;br /&gt;
    y := make([]int,10,10) //creates a slice [1...10]&lt;br /&gt;
    z := arr[0:10] //creates a slice [1...10]&lt;br /&gt;
    s1 := []int{1,2,3,4,5}&lt;br /&gt;
    s2 := append(s1, 6, 7)&lt;br /&gt;
    fmt.Println(s1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(s2) // [1,2,3,4,5,6,7]&lt;br /&gt;
    p1 := [] int{1,2,3,4,5}&lt;br /&gt;
    p2 :=make([]int, 4)&lt;br /&gt;
    copy(p2,p1)&lt;br /&gt;
    fmt.Println(p1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(p2)// [1,2,3,4]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Maps:&lt;br /&gt;
**A map is an unordered collection of key value pairs.&lt;br /&gt;
**Syntax: var x map[int] string , where int is the type of the key and string is the type of the value.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
    x := make(map[int]string)&lt;br /&gt;
    x[1] = one&lt;br /&gt;
    x[2] = two&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
&lt;br /&gt;
*In Go functions can take multiple inputs and return multiple outputs.&lt;br /&gt;
*Go supports a special kind of function called variadic function.&lt;br /&gt;
*Closure is the means by which functions can be created inside other function in Go.&lt;br /&gt;
*Go supports recursive functions.&lt;br /&gt;
*The example below the different types of function in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    display(“Hello World”)&lt;br /&gt;
    sum :=calculateSum(10,20)&lt;br /&gt;
    v1,v2=multipleValues()&lt;br /&gt;
    p=product(5,10,20)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function without return type&lt;br /&gt;
func display( s string) {&lt;br /&gt;
    fmt.Println(s)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns a single value&lt;br /&gt;
func calculateSum(a int, b int) int {&lt;br /&gt;
    c: = a + b&lt;br /&gt;
    return c&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns multiple values&lt;br /&gt;
func multipleValues(int, int) {&lt;br /&gt;
    return 1, 2&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Variadic function&lt;br /&gt;
func product(args ...int) int {&lt;br /&gt;
    p := 1&lt;br /&gt;
   for _, i := range args {&lt;br /&gt;
        p *= i&lt;br /&gt;
   }&lt;br /&gt;
   return p&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pointers==&lt;br /&gt;
It is used to reference a location in the memory where the value is stored rather than containing the value itself. Basic pointer operations in Go are illustrated in the example below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
//Different syntax for pointers&lt;br /&gt;
    &lt;br /&gt;
     ptr1 *int&lt;br /&gt;
     num :=10&lt;br /&gt;
     ptr1 = &amp;amp;num&lt;br /&gt;
     ptr2 := new(int)&lt;br /&gt;
     ptr2=&amp;amp;num&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Concurrency==&lt;br /&gt;
* Go ensures concurrency which allows sharing of state using communication mechanisms.&lt;br /&gt;
* Go provides support for multithreading and CPU parallelization.&lt;br /&gt;
* Go supports asynchrony i.e. allows operations like database and network I/O which are slow operations to occur in parallel along with other operations.&lt;br /&gt;
* A new lightweight process is created using go func().&lt;br /&gt;
* Channel types are used for providing type safe and synchronized channels between different go routines.&lt;br /&gt;
&lt;br /&gt;
=Users of Go=&lt;br /&gt;
Apart from Google, which uses Go programming for some of its development, companies like [http://en.wikipedia.org/wiki/Dropbox_(service) Dropbox], [http://en.wikipedia.org/wiki/CloudFlare CloudFlare], [http://en.wikipedia.org/wiki/SoundCloud SoundCloud], The BBC, Novartis, Cloud Foundry also use Go programming.  &lt;br /&gt;
Dropbox server (running in the cloud) and desktop client software were primarily written in [http://en.wikipedia.org/wiki/Python_(programming_language) Python]. From mid-2013 Dropbox began migrating its backend infrastructure to Go.&lt;br /&gt;
Some of the open-source applications that are using Go programming are Docker, Flynn, PaaS, Juju, nsq, Doozer e.t.c .&amp;lt;ref name = &amp;quot;GoWIKI&amp;quot;&amp;gt;[http://en.wikipedia.org/wiki/Go_(programming_language), Wikipedia]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advantages&amp;lt;ref name=&amp;quot;csdn&amp;quot;&amp;gt; [http://blog.csdn.net/lymemoryzz/article/details/20960997 CSDN blog]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
 &lt;br /&gt;
*'''C Level Performance'''. golang is within a close margin of the performance level of C code (which is itself an extremely high performance language). It is certainly closer to the performance of native languages than other enterprise level languages such as Java, Scala, Erlang etc.&lt;br /&gt;
 &lt;br /&gt;
*'''Fast Compilation''' is one of the key advantages of Go language. The Golang compiler was designed to compile programs very quickly. Extremely large programs with massively high LOC counts compile seemingly instantly - after all, Golang was designed by Google to solve Google problems, and Google has big problems! At Google, code and CPU cores are both measured in the millions. Go provides a model for software construction that makes dependency analysis easy and avoids much of the overhead of C-style include files and libraries.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reduced compile time is a key improvement in the Go language&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      If A.go depends on B.go depends on C.go :&lt;br /&gt;
         Compile C.go, B.go then A.go normally (other languages)&lt;br /&gt;
         To compile A.go, compiler reads B.o not C.o (go)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At a large scale this should help in hugely speeding up&lt;br /&gt;
&lt;br /&gt;
Other advantages are      &lt;br /&gt;
* '''Concurrency Supported At Language Level'''. Concurrency is the ability to execute multiple computations simultaneously. In today's modern multicore and high-load computing environment, concurrency is a critical language feature, and one in which languages such as Java struggle immensely.&lt;br /&gt;
* By its design, Go proposes an approach for the construction of system software on '''multicore machines'''.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
* Google have summed things up nicely with their motto: '''Don't communicate by sharing memory, share memory by communicating'''.Channels allow you to pass references to data structures between goroutines. If you consider this as passing around ownership of the data (the ability to read and write it), they become a powerful and expressive synchronization mechanism.  &lt;br /&gt;
* '''Go's type system has no hierarchy''', so no time is spent defining the relationships between types. Also, although Go has static types, the language attempts to make types feel lighter weight than in typical Object Oriented languages.&lt;br /&gt;
* '''Garbage Collection is much better'''. In C and C++, programmers spend a lot of time and energy on allocating and freeing memory. The designers of Go wanted to remove that complication, and ensure Go programmers could concentrate on more productive tasks. As such, they implemented garbage collection. As a developer, this is a very good thing. Sure, garbage collection comes with its own set of issues, but those are dealt with by the language implementer while the programmer is free to reap the other many benefits of Go.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
*Go is still an experimental language subject to change.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;&amp;gt;[http://stackoverflow.com/questions/2198529/what-are-the-advantages-and-disadvantages-of-go-programming-language stackoverflow]&amp;lt;/ref&amp;gt;&lt;br /&gt;
*Go's not very usable on Windows yet.&lt;br /&gt;
*The packages distributed with Go are pretty useful, but there are still some libraries you'll miss. Most notably a UI toolkit.&lt;br /&gt;
*There is no support for generics in Go, although there are many discussions around it.&lt;br /&gt;
*Confusing Semantics Of Exported Identifiers&amp;lt;ref name = &amp;quot;Limitations2&amp;quot;&amp;gt;&lt;br /&gt;
[https://functionwhatwhat.com/go’s-type-system-is-an-embarrassment functionwhatwhat ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
=Additional References=&lt;br /&gt;
*[http://tour.golang.org Golang tour]&lt;br /&gt;
*[http://golangtutorials.blogspot.com/2011/05/table-of-contents.html Golang tutorials]&lt;br /&gt;
*[http://go.googlecode.com/hg-history/release-branch.r60/doc/GoCourseDay1.pdf GoCourseDay1]&lt;br /&gt;
*[https://www.youtube.com/watch?v=rKnDgT73v8s Go programming language tutorial video]&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=88593</id>
		<title>CSC/ECE 517 Fall 2014/ch1a 10 hu</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=88593"/>
		<updated>2014-09-26T01:15:19Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==''' Go Programming Language''' ==&lt;br /&gt;
'''Go''', also commonly referred to as '''golang''', is a compiled, concurrent, garbage-collected, statically typed language developed at [http://en.wikipedia.org/wiki/Google Google]. It was developed by [http://en.wikipedia.org/wiki/Robert_Griesemer Robert Griesemer], [http://en.wikipedia.org/wiki/Rob_Pike Rob Pike] and [http://en.wikipedia.org/wiki/Ken_Thompson Ken Thompson] in 2007. It was announced in November 2009 and is currently being used in many production systems at Google. It is an open source project. The syntax is loosely derived from that of [http://en.wikipedia.org/wiki/C_(programming_language) C programming language], adding [http://en.wikipedia.org/wiki/Garbage_collection_(computer_science) garbage collection], type safety, some dynamic-typing capabilities. Additional built-in types such as variable-length arrays and key-value maps, and a large standard library are also supported. Different operating systems like Linux, Microsoft Windows, Mac OS X are suported by [https://golang.org/cmd/gc Gc] compiler of Go.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
&lt;br /&gt;
Go programming started of as a research project by Robert Griesemer, Rob Pike and Ken Thompson. They felt that there was no new system focused programming language that has come up in the last decade till 2008, while there were other developments like increase in the size of libraries, dominance of networking , client server focus, multi-core CPUs.&amp;lt;ref name = &amp;quot;Background 1&amp;quot;&amp;gt;[https://www.youtube.com/watch?v=rKnDgT73v8s Go Language Introduction speech]&amp;lt;/ref&amp;gt; So they wanted to come up with a new systems focused programming language that would address the above issues.&amp;lt;ref name=&amp;quot;BG2&amp;quot;&amp;gt;[http://techcrunch.com/2009/11/10/google-go-language TechCrunch]&amp;lt;/ref&amp;gt; They started sketching the goals for a new language on the white board on September 21, 2007. Within a few days the goals had settled into a plan to do something and a fair idea of what it would be. Design continued part-time in parallel with unrelated work.&lt;br /&gt;
By January 2008, Ken had started work on a compiler with which to explore ideas; it generated C code as its output. By mid-year the language had become a full-time project and had settled enough to attempt a production compiler. In May 2008, [http://research.google.com/pubs/author37504.html Ian Taylor] independently started on a [http://en.wikipedia.org/wiki/GNU_Compiler_Collection GCC] front end for Go using the draft specification.  [http://russ.cox.usesthis.com/ Russ Cox] joined in late 2008 and helped move the language and libraries from prototype to reality.&lt;br /&gt;
Go became a public [http://en.wikipedia.org/wiki/Open_source open source project] on November 10, 2009. Many people from the community have contributed ideas, discussions, and code.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Compilers and Runtime support=&lt;br /&gt;
&lt;br /&gt;
There are two Go compiler implementations, [https://golang.org/cmd/gc Gc] (the 6g program and friends) and [http://blog.golang.org/gccgo-in-gcc-471 gccgo ]. Gc uses a different calling convention and linker. It can therefore only be linked with C programs using the same convention. Gccgo is a GCC front-end that can be linked with GCC-compiled C or C++ programs.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cgo program provides the mechanism for a “foreign function interface” to allow safe calling of C libraries from Go code. [http://en.wikipedia.org/wiki/SWIG SWIG] extends this capability to C++ libraries. &lt;br /&gt;
&lt;br /&gt;
Again due to bootstrapping issues, the run-time code is mostly in C (with a tiny bit of assembler) although Go is capable of implementing most of it now. Gccgo's run-time support uses glibc. Gc uses a custom library to keep the footprint under control; it is compiled with a version of the [http://plan9.bell-labs.com/sys/doc/compiler.html Plan 9 C compiler] that supports resizable stacks for goroutines. The gccgo compiler implements these on Linux only, using a technique called segmented stacks, supported by recent modifications to the gold linker.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find all resources needed to compile and run Go Language here http://go-lang.cat-v.org/&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
 &lt;br /&gt;
Programming today involves too much bookkeeping, repetition, and clerical work. As Dick Gabriel says, “Old programs read like quiet conversations between a well-spoken research worker and a well-studied mechanical colleague, not as a debate with a compiler. Who'd have guessed sophistication bought such noise?” The sophistication is worthwhile—no one wants to go back to the old languages—but can it be more quietly achieved?&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Go attempts to reduce the amount of typing in both senses of the word. Throughout its design, &lt;br /&gt;
*They have tried to reduce clutter and complexity. &lt;br /&gt;
*There are no forward declarations and no header files. everything is declared exactly once. &lt;br /&gt;
*Initialization is expressive, automatic, and easy to use. &lt;br /&gt;
*Syntax is clean and light on keywords. Stuttering (foo.Foo* myFoo = new(foo.Foo)) is reduced by simple type derivation using the := declare-and-initialize construct. &lt;br /&gt;
*And perhaps most radically, there is no type hierarchy. They don't have to announce their relationships.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
These simplifications allow Go to be expressive yet comprehensible without sacrificing, well, sophistication.&lt;br /&gt;
Another important principle is to keep the concepts orthogonal. Methods can be implemented for any type; structures represent data while interfaces represent abstraction; and so on. Orthogonality makes it easier to understand what happens when things combine.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Comparison between Go Programming and C++ Programming language &amp;lt;ref name=&amp;quot;KTH&amp;quot;&amp;gt;[http://www.csc.kth.se/utbildning/kth/kurser/DD143X/dkand11/Group9Alexander/Joakim_Anneback_Johan_Stjernberg.finalreport.2.pdf KTH comparison]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;quora&amp;quot;&amp;gt;[http://www.quora.com/How-does-Go-compare-to-C++-and-Java Quora comparison]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;Scriptol&amp;quot;&amp;gt;[http://www.scriptol.com/programming/go.php scriptol]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
Go programming language was developed to run as fast as C++ programs while adding a lot of other modern day features. Some of the key differeneces are listed below&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;2&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Points of Comparison&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Go Programming Language&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | C++ Programming Language&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Primary Focus'''&lt;br /&gt;
|| Go focuses on garbage collection, concurrency and compiling quickly&lt;br /&gt;
|| C++ focuses on inheritance, generic types and pointer arithmetics.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Variable Sizes'''&lt;br /&gt;
|| Machine-independent types are now included without an import needed:  int8, int16, int32, int64, uint8, etc.&lt;br /&gt;
|| Machine-dependent variable sizes&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Class Hierarchies'''&lt;br /&gt;
|| Inheritance is not supported , but with the traditional structures with plain old functions and namespaces, is a MUCH &lt;br /&gt;
better, more flexible approach that leads to better, more maintainable code. &lt;br /&gt;
|| Inheritance is supported but it has its own share of problems like diamond inheritance, virtual inheritance and normal inheritance.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Function overloading'''&lt;br /&gt;
|| Not present in Go because it simplifies dispatch.	&lt;br /&gt;
|| Present in C++.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Genrics'''&lt;br /&gt;
|| Go does not currently support generic types. However, it does support objects without a type using the empty interface.&lt;br /&gt;
|| C++ on the other hand has support for generic types. Generic programming is supported by the use of function templates, class templates and, in some cases, specialized templates in C++.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Multithreading'''&lt;br /&gt;
|| Goroutines are Go's model of threads/coroutines. Each new goroutine runs in parallel with the current computation, in &amp;quot;the same address space. Goroutines are cheap and developers need not to &lt;br /&gt;
worry about the stack size.&lt;br /&gt;
|| In contrast, there is currently no built-in way to manage threads in C++, although the feature is expected in the upcoming new standard and is already today possible using third-party libraries. &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Garbage Collection'''&lt;br /&gt;
|| Go uses garbage collection for memory management, which means that if frees the programmer completely from keeping a track on the memory used.&lt;br /&gt;
|| C++ does not have any garbage collection and hence relies heavily on that the programmer knows what he or she is doing.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Language Design&amp;lt;ref name = &amp;quot;GoLang Book&amp;quot;&amp;gt;[http://www.golang-book.com, GoLang Book]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 package main //line 1&lt;br /&gt;
&lt;br /&gt;
   import “fmt”  //line 2&lt;br /&gt;
&lt;br /&gt;
   func main() {  //line 3&lt;br /&gt;
&lt;br /&gt;
       fmt.Println(“Hello World”) //line 4&lt;br /&gt;
&lt;br /&gt;
   } //line 5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The program above depicts the basic syntax of a program written using Go. Line1 specifies package declaration. Package is used to organize and reuse code. Line 2 is used for including the package “fmt” which is used for formatting input and output. Line 3 to 5 defines the function main. main is the function which is called when a program is executed. Println function in fmt is used to display content to the console i.e in this example Hello World is displayed in the console on executing the program.&lt;br /&gt;
&lt;br /&gt;
==Code Conventions and Style==&lt;br /&gt;
&lt;br /&gt;
* Go fmt tool is used to automatically standardize indentation, spaces and surface-level code details (go vet and go link perform checking automatically).&lt;br /&gt;
* Using tools and libraries provided in Go, there are standard approaches for API documentation (go doc), testing (go test), building( go build) and package management(go get).&lt;br /&gt;
* Syntax prevents any kind of cyclic dependencies.&lt;br /&gt;
* Unused variables and imports are not allowed.&lt;br /&gt;
* Elimination of functional programming constructs (such as map and try/finally) ensure a concrete and explicit programming style.&lt;br /&gt;
&lt;br /&gt;
==Types==&lt;br /&gt;
&lt;br /&gt;
* Numbers are represented in Go as either Integers or Floating point numbers.&lt;br /&gt;
**Integers: Used to represent numbers without a decimal component. Different integers supported by Go are: uint8, uint16, uint32, uint64, int8, int16, int32, int64. Uint is used for unsigned integers and int for signed. 8,16, 32, 64 indicate the number of bits each type would use.&lt;br /&gt;
**Floating Point Integers: Used to support decimal components. Go supports float32 and float64 to represent floating point numbers and complex32 and complex64 to represent complex numbers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var x int32 =4&lt;br /&gt;
var y float32 = 4.5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* String: String literals can be created using either double quotes(“Hello”) or back ticks(`Hello`). Strings have several operations associated them, for example one can find the length of the string or get a character at a specific index in a string. Example below illustrates these functions.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
	fmt.Println(len(“Hello”)) // output: 5&lt;br /&gt;
	fmt.Println(“Hello”[1]) // output: e&lt;br /&gt;
	fmt.Println(“Hello “+”Tom”) //output: Hello Tom&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Boolean: A 1 bit value is used to represent true or false.&lt;br /&gt;
&lt;br /&gt;
==Variables and Constants==&lt;br /&gt;
*Variabes in Go are indicated using the var keyword. Example: var x string=”hello” . They can also be shorthanded as x:=”hello” .&lt;br /&gt;
*The variable names should begin with a letter and can contain letters, digits or underscore character.&lt;br /&gt;
*The scope of the variable is the block in which it is defined and an attempt to access it outside the block would result in an error on running the program.&lt;br /&gt;
*Go provides support for constants (i.e. variables whose value can not be changed), using the const keyword. Example: const temp string = “Hello”&lt;br /&gt;
*In Go one can define multiple variables(or constants) using the following syntax:&lt;br /&gt;
    var(&lt;br /&gt;
         t1 =1&lt;br /&gt;
         t2=2&lt;br /&gt;
         t3=3&lt;br /&gt;
        t4=4&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Control Structures==&lt;br /&gt;
*For: It is used for repeating a list of statement(s) multiple times. The example below is used for calculating sum of numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    i := 1&lt;br /&gt;
    sum := 0&lt;br /&gt;
&lt;br /&gt;
    for i &amp;lt;= 10 {&lt;br /&gt;
        sum = sum + i&lt;br /&gt;
        i = i + 1&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    fmt.Println(“Sum:” + sum)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the example above i is a loop counter variable and is used to ensure that sum of numbers from 1 to 10 is computed. It indicates the number of times the statements inside the for loop are to be executed. The statement following the keyword for should evaluate to either true or false. If it is evaluated to true the body of for is executed, else we come out of the for loop.&lt;br /&gt;
&lt;br /&gt;
*If: Used to execute a block of statement(s) based on the evaluation of an expression to either true or false. It can also have an else associated with it.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    if i % 2 == 0 {&lt;br /&gt;
        fmt.Println(i + ” is divisble by 2”)&lt;br /&gt;
    } else {&lt;br /&gt;
        fmt.Println(i + “is not divisible by 2”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Switch: The value of the expression following switch is evaluated and is compared against the different cases. Based on the matching case, the block following that case is executed. Switch also has a default case in situations when none of the cases are matching.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    // if op ==1 then so a+b&lt;br /&gt;
    // if op == 2 then do a-b&lt;br /&gt;
    // if op == 3 then do a*b&lt;br /&gt;
    // if op ==4 then do a/b&lt;br /&gt;
    // default print, invalid operator&lt;br /&gt;
&lt;br /&gt;
    op:= 1&lt;br /&gt;
    a=6&lt;br /&gt;
    b=7&lt;br /&gt;
    switch(op) {&lt;br /&gt;
        case 1: fmt.Println(a+b)&lt;br /&gt;
        case 2: fmt.Println(a-b)&lt;br /&gt;
        case 3: fmt.Println(a*b)&lt;br /&gt;
        case 4: fmt.Println(a/b)&lt;br /&gt;
        default: fmt.Println(“Invalid Operator”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Arrays, Slices and Maps==&lt;br /&gt;
&lt;br /&gt;
*Arrays: Numbered sequence of elements starting with index zero and each of the elements having a fixed length. The example below illustrates various operations performed on arrays in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
    var x[10] int&lt;br /&gt;
    x[99]=100&lt;br /&gt;
    fmt.Println(x)  //[0 0 ….. 0 100]&lt;br /&gt;
    fmt.Println(len(x)) //100&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Slices: &lt;br /&gt;
** It is a segment of an array.&lt;br /&gt;
** They have a length and are indexable.&lt;br /&gt;
**In case of a slice the size does not have to specified in the square bracket.&lt;br /&gt;
**Slices support two in-build functions: copy and append.&lt;br /&gt;
**The program below illustrates the different ways to create slices and use of copy and append.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    arr := [10] int {1,2,3,4,5,6,7,8,9,10}&lt;br /&gt;
    x := make([]int,10) // creates a slice [1...10]&lt;br /&gt;
    y := make([]int,10,10) //creates a slice [1...10]&lt;br /&gt;
    z := arr[0:10] //creates a slice [1...10]&lt;br /&gt;
    s1 := []int{1,2,3,4,5}&lt;br /&gt;
    s2 := append(s1, 6, 7)&lt;br /&gt;
    fmt.Println(s1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(s2) // [1,2,3,4,5,6,7]&lt;br /&gt;
    p1 := [] int{1,2,3,4,5}&lt;br /&gt;
    p2 :=make([]int, 4)&lt;br /&gt;
    copy(p2,p1)&lt;br /&gt;
    fmt.Println(p1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(p2)// [1,2,3,4]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Maps:&lt;br /&gt;
**A map is an unordered collection of key value pairs.&lt;br /&gt;
**Syntax: var x map[int] string , where int is the type of the key and string is the type of the value.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
    x := make(map[int]string)&lt;br /&gt;
    x[1] = one&lt;br /&gt;
    x[2] = two&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
&lt;br /&gt;
*In Go functions can take multiple inputs and return multiple outputs.&lt;br /&gt;
*Go supports a special kind of function called variadic function.&lt;br /&gt;
*Closure is the means by which functions can be created inside other function in Go.&lt;br /&gt;
*Go supports recursive functions.&lt;br /&gt;
*The example below the different types of function in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    display(“Hello World”)&lt;br /&gt;
    sum :=calculateSum(10,20)&lt;br /&gt;
    v1,v2=multipleValues()&lt;br /&gt;
    p=product(5,10,20)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function without return type&lt;br /&gt;
func display( s string) {&lt;br /&gt;
    fmt.Println(s)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns a single value&lt;br /&gt;
func calculateSum(a int, b int) int {&lt;br /&gt;
    c: = a + b&lt;br /&gt;
    return c&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns multiple values&lt;br /&gt;
func multipleValues(int, int) {&lt;br /&gt;
    return 1, 2&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Variadic function&lt;br /&gt;
func product(args ...int) int {&lt;br /&gt;
    p := 1&lt;br /&gt;
   for _, i := range args {&lt;br /&gt;
        p *= i&lt;br /&gt;
   }&lt;br /&gt;
   return p&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pointers==&lt;br /&gt;
It is used to reference a location in the memory where the value is stored rather than containing the value itself. Basic pointer operations in Go are illustrated in the example below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
//Different syntax for pointers&lt;br /&gt;
    &lt;br /&gt;
     ptr1 *int&lt;br /&gt;
     num :=10&lt;br /&gt;
     ptr1 = &amp;amp;num&lt;br /&gt;
     ptr2 := new(int)&lt;br /&gt;
     ptr2=&amp;amp;num&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Concurrency==&lt;br /&gt;
* Go ensures concurrency which allows sharing of state using communication mechanisms.&lt;br /&gt;
* Go provides support for multithreading and CPU parallelization.&lt;br /&gt;
* Go supports asynchrony i.e. allows operations like database and network I/O which are slow operations to occur in parallel along with other operations.&lt;br /&gt;
* A new lightweight process is created using go func().&lt;br /&gt;
* Channel types are used for providing type safe and synchronized channels between different go routines.&lt;br /&gt;
&lt;br /&gt;
=Users of Go=&lt;br /&gt;
Apart from Google, which uses Go programming for some of its development, companies like [http://en.wikipedia.org/wiki/Dropbox_(service) Dropbox], [http://en.wikipedia.org/wiki/CloudFlare CloudFlare], [http://en.wikipedia.org/wiki/SoundCloud SoundCloud], The BBC, Novartis, Cloud Foundry also use Go programming.  &lt;br /&gt;
Dropbox server (running in the cloud) and desktop client software were primarily written in [http://en.wikipedia.org/wiki/Python_(programming_language) Python]. From mid-2013 Dropbox began migrating its backend infrastructure to Go.&lt;br /&gt;
Some of the open-source applications that are using Go programming are Docker, Flynn, PaaS, Juju, nsq, Doozer e.t.c .&amp;lt;ref name = &amp;quot;GoWIKI&amp;quot;&amp;gt;[http://en.wikipedia.org/wiki/Go_(programming_language), Wikipedia]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advantages&amp;lt;ref name=&amp;quot;csdn&amp;quot;&amp;gt; [http://blog.csdn.net/lymemoryzz/article/details/20960997 CSDN blog]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
 &lt;br /&gt;
*'''C Level Performance'''. golang is within a close margin of the performance level of C code (which is itself an extremely high performance language). It is certainly closer to the performance of native languages than other enterprise level languages such as Java, Scala, Erlang etc.&lt;br /&gt;
 &lt;br /&gt;
*'''Fast Compilation''' is one of the key advantages of Go language. The Golang compiler was designed to compile programs very quickly. Extremely large programs with massively high LOC counts compile seemingly instantly - after all, Golang was designed by Google to solve Google problems, and Google has big problems! At Google, code and CPU cores are both measured in the millions. Go provides a model for software construction that makes dependency analysis easy and avoids much of the overhead of C-style include files and libraries.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reduced compile time is a key improvement in the Go language&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      If A.go depends on B.go depends on C.go :&lt;br /&gt;
         Compile C.go, B.go then A.go normally (other languages)&lt;br /&gt;
         To compile A.go, compiler reads B.o not C.o (go)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At a large scale this should help in hugely speeding up&lt;br /&gt;
&lt;br /&gt;
Other advantages are      &lt;br /&gt;
* '''Concurrency Supported At Language Level'''. Concurrency is the ability to execute multiple computations simultaneously. In today's modern multicore and high-load computing environment, concurrency is a critical language feature, and one in which languages such as Java struggle immensely.&lt;br /&gt;
* By its design, Go proposes an approach for the construction of system software on '''multicore machines'''.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
* Google have summed things up nicely with their motto: '''Don't communicate by sharing memory, share memory by communicating'''.Channels allow you to pass references to data structures between goroutines. If you consider this as passing around ownership of the data (the ability to read and write it), they become a powerful and expressive synchronization mechanism.  &lt;br /&gt;
* '''Go's type system has no hierarchy''', so no time is spent defining the relationships between types. Also, although Go has static types, the language attempts to make types feel lighter weight than in typical Object Oriented languages.&lt;br /&gt;
* '''Garbage Collection is much better'''. In C and C++, programmers spend a lot of time and energy on allocating and freeing memory. The designers of Go wanted to remove that complication, and ensure Go programmers could concentrate on more productive tasks. As such, they implemented garbage collection. As a developer, this is a very good thing. Sure, garbage collection comes with its own set of issues, but those are dealt with by the language implementer while the programmer is free to reap the other many benefits of Go.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
*Go is still an experimental language subject to change.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;&amp;gt;[http://stackoverflow.com/questions/2198529/what-are-the-advantages-and-disadvantages-of-go-programming-language stackoverflow]&amp;lt;/ref&amp;gt;&lt;br /&gt;
*Go's not very usable on Windows yet.&lt;br /&gt;
*The packages distributed with Go are pretty useful, but there are still some libraries you'll miss. Most notably a UI toolkit.&lt;br /&gt;
*There is no support for generics in Go, although there are many discussions around it.&lt;br /&gt;
*Confusing Semantics Of Exported Identifiers&amp;lt;ref name = &amp;quot;Limitations2&amp;quot;&amp;gt;&lt;br /&gt;
[https://functionwhatwhat.com/go’s-type-system-is-an-embarrassment functionwhatwhat ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
=Additional References=&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=88581</id>
		<title>CSC/ECE 517 Fall 2014/ch1a 10 hu</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=88581"/>
		<updated>2014-09-26T00:58:33Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Concurrency */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==''' Go Programming Language''' ==&lt;br /&gt;
'''Go''', also commonly referred to as '''golang''', is a compiled, concurrent, garbage-collected, statically typed language developed at [http://en.wikipedia.org/wiki/Google Google]. It was developed by [http://en.wikipedia.org/wiki/Robert_Griesemer Robert Griesemer], [http://en.wikipedia.org/wiki/Rob_Pike Rob Pike] and [http://en.wikipedia.org/wiki/Ken_Thompson Ken Thompson] in 2007. It was announced in November 2009 and is currently being used in many production systems at Google. It is an open source project. The syntax is loosely derived from that of [http://en.wikipedia.org/wiki/C_(programming_language) C programming language], adding [http://en.wikipedia.org/wiki/Garbage_collection_(computer_science) garbage collection], type safety, some dynamic-typing capabilities. Additional built-in types such as variable-length arrays and key-value maps, and a large standard library are also supported. Different operating systems like Linux, Microsoft Windows, Mac OS X are suported by [https://golang.org/cmd/gc Gc] compiler of Go.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
&lt;br /&gt;
Go programming started of as a research project by Robert Griesemer, Rob Pike and Ken Thompson. They felt that there was no new system focused programming language that has come up in the last decade till 2008, while there were other developments like increase in the size of libraries, dominance of networking , client server focus, multi-core CPUs.&amp;lt;ref name = &amp;quot;Background 1&amp;quot;&amp;gt;[https://www.youtube.com/watch?v=rKnDgT73v8s Go Language Introduction speech]&amp;lt;/ref&amp;gt; So they wanted to come up with a new systems focused programming language that would address the above issues.&amp;lt;ref name=&amp;quot;BG2&amp;quot;&amp;gt;[http://techcrunch.com/2009/11/10/google-go-language TechCrunch]&amp;lt;/ref&amp;gt; They started sketching the goals for a new language on the white board on September 21, 2007. Within a few days the goals had settled into a plan to do something and a fair idea of what it would be. Design continued part-time in parallel with unrelated work.&lt;br /&gt;
By January 2008, Ken had started work on a compiler with which to explore ideas; it generated C code as its output. By mid-year the language had become a full-time project and had settled enough to attempt a production compiler. In May 2008, [http://research.google.com/pubs/author37504.html Ian Taylor] independently started on a [http://en.wikipedia.org/wiki/GNU_Compiler_Collection GCC] front end for Go using the draft specification.  [http://russ.cox.usesthis.com/ Russ Cox] joined in late 2008 and helped move the language and libraries from prototype to reality.&lt;br /&gt;
Go became a public [http://en.wikipedia.org/wiki/Open_source open source project] on November 10, 2009. Many people from the community have contributed ideas, discussions, and code.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Compilers and Runtime support=&lt;br /&gt;
&lt;br /&gt;
There are two Go compiler implementations, [https://golang.org/cmd/gc Gc] (the 6g program and friends) and [http://blog.golang.org/gccgo-in-gcc-471 gccgo ]. Gc uses a different calling convention and linker. It can therefore only be linked with C programs using the same convention. Gccgo is a GCC front-end that can be linked with GCC-compiled C or C++ programs.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cgo program provides the mechanism for a “foreign function interface” to allow safe calling of C libraries from Go code. [http://en.wikipedia.org/wiki/SWIG SWIG] extends this capability to C++ libraries. &lt;br /&gt;
&lt;br /&gt;
Again due to bootstrapping issues, the run-time code is mostly in C (with a tiny bit of assembler) although Go is capable of implementing most of it now. Gccgo's run-time support uses glibc. Gc uses a custom library to keep the footprint under control; it is compiled with a version of the [http://plan9.bell-labs.com/sys/doc/compiler.html Plan 9 C compiler] that supports resizable stacks for goroutines. The gccgo compiler implements these on Linux only, using a technique called segmented stacks, supported by recent modifications to the gold linker.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find all resources needed to compile and run Go Language here http://go-lang.cat-v.org/&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
 &lt;br /&gt;
Programming today involves too much bookkeeping, repetition, and clerical work. As Dick Gabriel says, “Old programs read like quiet conversations between a well-spoken research worker and a well-studied mechanical colleague, not as a debate with a compiler. Who'd have guessed sophistication bought such noise?” The sophistication is worthwhile—no one wants to go back to the old languages—but can it be more quietly achieved?&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Go attempts to reduce the amount of typing in both senses of the word. Throughout its design, &lt;br /&gt;
*They have tried to reduce clutter and complexity. &lt;br /&gt;
*There are no forward declarations and no header files. everything is declared exactly once. &lt;br /&gt;
*Initialization is expressive, automatic, and easy to use. &lt;br /&gt;
*Syntax is clean and light on keywords. Stuttering (foo.Foo* myFoo = new(foo.Foo)) is reduced by simple type derivation using the := declare-and-initialize construct. &lt;br /&gt;
*And perhaps most radically, there is no type hierarchy. They don't have to announce their relationships.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
These simplifications allow Go to be expressive yet comprehensible without sacrificing, well, sophistication.&lt;br /&gt;
Another important principle is to keep the concepts orthogonal. Methods can be implemented for any type; structures represent data while interfaces represent abstraction; and so on. Orthogonality makes it easier to understand what happens when things combine.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Comparison between Go Programming and C++ Programming language &amp;lt;ref name=&amp;quot;KTH&amp;quot;&amp;gt;[http://www.csc.kth.se/utbildning/kth/kurser/DD143X/dkand11/Group9Alexander/Joakim_Anneback_Johan_Stjernberg.finalreport.2.pdf KTH comparison]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;quora&amp;quot;&amp;gt;[http://www.quora.com/How-does-Go-compare-to-C++-and-Java Quora comparison]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;Scriptol&amp;quot;&amp;gt;[http://www.scriptol.com/programming/go.php scriptol]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
Go programming language was developed to run as fast as C++ programs while adding a lot of other modern day features. Some of the key differeneces are listed below&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;2&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Points of Comparison&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Go Programming Language&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | C++ Programming Language&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Primary Focus'''&lt;br /&gt;
|| Go focuses on garbage collection, concurrency and compiling quickly&lt;br /&gt;
|| C++ focuses on inheritance, generic types and pointer arithmetics.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Variable Sizes'''&lt;br /&gt;
|| Machine-independent types are now included without an import needed:  int8, int16, int32, int64, uint8, etc.&lt;br /&gt;
|| Machine-dependent variable sizes&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Class Hierarchies'''&lt;br /&gt;
|| Inheritance is not supported , but with the traditional structures with plain old functions and namespaces, is a MUCH &lt;br /&gt;
better, more flexible approach that leads to better, more maintainable code. &lt;br /&gt;
|| Inheritance is supported but it has its own share of problems like diamond inheritance, virtual inheritance and normal inheritance.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Function overloading'''&lt;br /&gt;
|| Not present in Go because it simplifies dispatch.	&lt;br /&gt;
|| Present in C++.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Genrics'''&lt;br /&gt;
|| Go does not currently support generic types. However, it does support objects without a type using the empty interface.&lt;br /&gt;
|| C++ on the other hand has support for generic types. Generic programming is supported by the use of function templates, class templates and, in some cases, specialized templates in C++.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Multithreading'''&lt;br /&gt;
|| Goroutines are Go's model of threads/coroutines. Each new goroutine runs in parallel with the current computation, in &amp;quot;the same address space. Goroutines are cheap and developers need not to &lt;br /&gt;
worry about the stack size.&lt;br /&gt;
|| In contrast, there is currently no built-in way to manage threads in C++, although the feature is expected in the upcoming new standard and is already today possible using third-party libraries. &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Garbage Collection'''&lt;br /&gt;
|| Go uses garbage collection for memory management, which means that if frees the programmer completely from keeping a track on the memory used.&lt;br /&gt;
|| C++ does not have any garbage collection and hence relies heavily on that the programmer knows what he or she is doing.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Language Design&amp;lt;ref name = &amp;quot;GoLang Book&amp;quot;&amp;gt;[http://www.golang-book.com, GoLang Book]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 package main //line 1&lt;br /&gt;
&lt;br /&gt;
   import “fmt”  //line 2&lt;br /&gt;
&lt;br /&gt;
   func main() {  //line 3&lt;br /&gt;
&lt;br /&gt;
       fmt.Println(“Hello World”) //line 4&lt;br /&gt;
&lt;br /&gt;
   } //line 5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The program above depicts the basic syntax of a program written using Go. Line1 specifies package declaration. Package is used to organize and reuse code. Line 2 is used for including the package “fmt” which is used for formatting input and output. Line 3 to 5 defines the function main. main is the function which is called when a program is executed. Println function in fmt is used to display content to the console i.e in this example Hello World is displayed in the console on executing the program.&lt;br /&gt;
&lt;br /&gt;
==Code Conventions and Style==&lt;br /&gt;
&lt;br /&gt;
* Go fmt tool is used to automatically standardize indentation, spaces and surface-level code details (go vet and go link perform checking automatically).&lt;br /&gt;
* Using tools and libraries provided in Go, there are standard approaches for API documentation (go doc), testing (go test), building( go build) and package management(go get).&lt;br /&gt;
* Syntax prevents any kind of cyclic dependencies.&lt;br /&gt;
* Unused variables and imports are not allowed.&lt;br /&gt;
* Elimination of functional programming constructs (such as map and try/finally) ensure a concrete and explicit programming style.&lt;br /&gt;
&lt;br /&gt;
==Types==&lt;br /&gt;
&lt;br /&gt;
* Numbers are represented in Go as either Integers or Floating point numbers.&lt;br /&gt;
**Integers: Used to represent numbers without a decimal component. Different integers supported by Go are: uint8, uint16, uint32, uint64, int8, int16, int32, int64. Uint is used for unsigned integers and int for signed. 8,16, 32, 64 indicate the number of bits each type would use.&lt;br /&gt;
**Floating Point Integers: Used to support decimal components. Go supports float32 and float64 to represent floating point numbers and complex32 and complex64 to represent complex numbers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var x int32 =4&lt;br /&gt;
var y float32 = 4.5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* String: String literals can be created using either double quotes(“Hello”) or back ticks(`Hello`). Strings have several operations associated them, for example one can find the length of the string or get a character at a specific index in a string. Example below illustrates these functions.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
	fmt.Println(len(“Hello”)) // output: 5&lt;br /&gt;
	fmt.Println(“Hello”[1]) // output: e&lt;br /&gt;
	fmt.Println(“Hello “+”Tom”) //output: Hello Tom&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Boolean: A 1 bit value is used to represent true or false.&lt;br /&gt;
&lt;br /&gt;
==Variables and Constants==&lt;br /&gt;
*Variabes in Go are indicated using the var keyword. Example: var x string=”hello” . They can also be shorthanded as x:=”hello” .&lt;br /&gt;
*The variable names should begin with a letter and can contain letters, digits or underscore character.&lt;br /&gt;
*The scope of the variable is the block in which it is defined and an attempt to access it outside the block would result in an error on running the program.&lt;br /&gt;
*Go provides support for constants (i.e. variables whose value can not be changed), using the const keyword. Example: const temp string = “Hello”&lt;br /&gt;
*In Go one can define multiple variables(or constants) using the following syntax:&lt;br /&gt;
    var(&lt;br /&gt;
         t1 =1&lt;br /&gt;
         t2=2&lt;br /&gt;
         t3=3&lt;br /&gt;
        t4=4&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Control Structures==&lt;br /&gt;
*For: It is used for repeating a list of statement(s) multiple times. The example below is used for calculating sum of numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    i := 1&lt;br /&gt;
    sum := 0&lt;br /&gt;
&lt;br /&gt;
    for i &amp;lt;= 10 {&lt;br /&gt;
        sum = sum + i&lt;br /&gt;
        i = i + 1&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    fmt.Println(“Sum:” + sum)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the example above i is a loop counter variable and is used to ensure that sum of numbers from 1 to 10 is computed. It indicates the number of times the statements inside the for loop are to be executed. The statement following the keyword for should evaluate to either true or false. If it is evaluated to true the body of for is executed, else we come out of the for loop.&lt;br /&gt;
&lt;br /&gt;
*If: Used to execute a block of statement(s) based on the evaluation of an expression to either true or false. It can also have an else associated with it.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    if i % 2 == 0 {&lt;br /&gt;
        fmt.Println(i + ” is divisble by 2”)&lt;br /&gt;
    } else {&lt;br /&gt;
        fmt.Println(i + “is not divisible by 2”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Switch: The value of the expression following switch is evaluated and is compared against the different cases. Based on the matching case, the block following that case is executed. Switch also has a default case in situations when none of the cases are matching.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    // if op ==1 then so a+b&lt;br /&gt;
    // if op == 2 then do a-b&lt;br /&gt;
    // if op == 3 then do a*b&lt;br /&gt;
    // if op ==4 then do a/b&lt;br /&gt;
    // default print, invalid operator&lt;br /&gt;
&lt;br /&gt;
    op:= 1&lt;br /&gt;
    a=6&lt;br /&gt;
    b=7&lt;br /&gt;
    switch(op) {&lt;br /&gt;
        case 1: fmt.Println(a+b)&lt;br /&gt;
        case 2: fmt.Println(a-b)&lt;br /&gt;
        case 3: fmt.Println(a*b)&lt;br /&gt;
        case 4: fmt.Println(a/b)&lt;br /&gt;
        default: fmt.Println(“Invalid Operator”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Arrays, Slices and Maps==&lt;br /&gt;
&lt;br /&gt;
*Arrays: Numbered sequence of elements starting with index zero and each of the elements having a fixed length. The example below illustrates various operations performed on arrays in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
    var x[10] int&lt;br /&gt;
    x[99]=100&lt;br /&gt;
    fmt.Println(x)  //[0 0 ….. 0 100]&lt;br /&gt;
    fmt.Println(len(x)) //100&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Slices: &lt;br /&gt;
** It is a segment of an array.&lt;br /&gt;
** They have a length and are indexable.&lt;br /&gt;
**In case of a slice the size does not have to specified in the square bracket.&lt;br /&gt;
**Slices support two in-build functions: copy and append.&lt;br /&gt;
**The program below illustrates the different ways to create slices and use of copy and append.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    arr := [10] int {1,2,3,4,5,6,7,8,9,10}&lt;br /&gt;
    x := make([]int,10) // creates a slice [1...10]&lt;br /&gt;
    y := make([]int,10,10) //creates a slice [1...10]&lt;br /&gt;
    z := arr[0:10] //creates a slice [1...10]&lt;br /&gt;
    s1 := []int{1,2,3,4,5}&lt;br /&gt;
    s2 := append(s1, 6, 7)&lt;br /&gt;
    fmt.Println(s1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(s2) // [1,2,3,4,5,6,7]&lt;br /&gt;
    p1 := [] int{1,2,3,4,5}&lt;br /&gt;
    p2 :=make([]int, 4)&lt;br /&gt;
    copy(p2,p1)&lt;br /&gt;
    fmt.Println(p1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(p2)// [1,2,3,4]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Maps:&lt;br /&gt;
**A map is an unordered collection of key value pairs.&lt;br /&gt;
**Syntax: var x map[int] string , where int is the type of the key and string is the type of the value.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
    x := make(map[int]string)&lt;br /&gt;
    x[1] = one&lt;br /&gt;
    x[2] = two&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
&lt;br /&gt;
*In Go functions can take multiple inputs and return multiple outputs.&lt;br /&gt;
*Go supports a special kind of function called variadic function.&lt;br /&gt;
*Closure is the means by which functions can be created inside other function in Go.&lt;br /&gt;
*Go supports recursive functions.&lt;br /&gt;
*The example below the different types of function in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    display(“Hello World”)&lt;br /&gt;
    sum :=calculateSum(10,20)&lt;br /&gt;
    v1,v2=multipleValues()&lt;br /&gt;
    p=product(5,10,20)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function without return type&lt;br /&gt;
func display( s string) {&lt;br /&gt;
    fmt.Println(s)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns a single value&lt;br /&gt;
func calculateSum(a int, b int) int {&lt;br /&gt;
    c: = a + b&lt;br /&gt;
    return c&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns multiple values&lt;br /&gt;
func multipleValues(int, int) {&lt;br /&gt;
    return 1, 2&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Variadic function&lt;br /&gt;
func product(args ...int) int {&lt;br /&gt;
    p := 1&lt;br /&gt;
   for _, i := range args {&lt;br /&gt;
        p *= i&lt;br /&gt;
   }&lt;br /&gt;
   return p&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pointers==&lt;br /&gt;
It is used to reference a location in the memory where the value is stored rather than containing the value itself. Basic pointer operations in Go are illustrated in the example below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
//Different syntax for pointers&lt;br /&gt;
    &lt;br /&gt;
     ptr1 *int&lt;br /&gt;
     num :=10&lt;br /&gt;
     ptr1 = &amp;amp;num&lt;br /&gt;
     ptr2 := new(int)&lt;br /&gt;
     ptr2=&amp;amp;num&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Concurrency==&lt;br /&gt;
* Go ensures concurrency which allows sharing of state using communication mechanisms.&lt;br /&gt;
* Go provides support for multithreading and CPU parallelization.&lt;br /&gt;
* Go supports asynchrony i.e. allows operations like database and network I/O which are slow operations to occur in parallel along with other operations.&lt;br /&gt;
* A new lightweight process is created using go func().&lt;br /&gt;
* Channel types are used for providing type safe and synchronized channels between different go routines.&lt;br /&gt;
&lt;br /&gt;
=Users of Go=&lt;br /&gt;
Apart from Google, which uses Go programming for some of its development, companies like [http://en.wikipedia.org/wiki/Dropbox_(service) Dropbox], [http://en.wikipedia.org/wiki/CloudFlare CloudFlare], [http://en.wikipedia.org/wiki/SoundCloud SoundCloud], The BBC, Novartis, Cloud Foundry also use Go programming.  &lt;br /&gt;
Dropbox server (running in the cloud) and desktop client software were primarily written in [http://en.wikipedia.org/wiki/Python_(programming_language) Python]. From mid-2013 Dropbox began migrating its backend infrastructure to Go.&lt;br /&gt;
Some of the open-source applications that are using Go programming are Docker, Flynn, PaaS, Juju, nsq, Doozer e.t.c .&amp;lt;ref name = &amp;quot;GoWIKI&amp;quot;&amp;gt;[http://en.wikipedia.org/wiki/Go_(programming_language), Wikipedia]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advantages&amp;lt;ref name=&amp;quot;csdn&amp;quot;&amp;gt; [http://blog.csdn.net/lymemoryzz/article/details/20960997 CSDN blog]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
 &lt;br /&gt;
*'''C Level Performance'''. golang is within a close margin of the performance level of C code (which is itself an extremely high performance language). It is certainly closer to the performance of native languages than other enterprise level languages such as Java, Scala, Erlang etc.&lt;br /&gt;
 &lt;br /&gt;
*'''Fast Compilation''' is one of the key advantages of Go language. The Golang compiler was designed to compile programs very quickly. Extremely large programs with massively high LOC counts compile seemingly instantly - after all, Golang was designed by Google to solve Google problems, and Google has big problems! At Google, code and CPU cores are both measured in the millions. Go provides a model for software construction that makes dependency analysis easy and avoids much of the overhead of C-style include files and libraries.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reduced compile time is a key improvement in the Go language&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      If A.go depends on B.go depends on C.go :&lt;br /&gt;
         Compile C.go, B.go then A.go normally (other languages)&lt;br /&gt;
         To compile A.go, compiler reads B.o not C.o (go)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At a large scale this should help in hugely speeding up&lt;br /&gt;
&lt;br /&gt;
Other advantages are      &lt;br /&gt;
* '''Concurrency Supported At Language Level'''. Concurrency is the ability to execute multiple computations simultaneously. In today's modern multicore and high-load computing environment, concurrency is a critical language feature, and one in which languages such as Java struggle immensely.&lt;br /&gt;
* By its design, Go proposes an approach for the construction of system software on '''multicore machines'''.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
* Google have summed things up nicely with their motto: '''Don't communicate by sharing memory, share memory by communicating'''.Channels allow you to pass references to data structures between goroutines. If you consider this as passing around ownership of the data (the ability to read and write it), they become a powerful and expressive synchronization mechanism.  &lt;br /&gt;
* '''Go's type system has no hierarchy''', so no time is spent defining the relationships between types. Also, although Go has static types, the language attempts to make types feel lighter weight than in typical Object Oriented languages.&lt;br /&gt;
* '''Garbage Collection is much better'''. In C and C++, programmers spend a lot of time and energy on allocating and freeing memory. The designers of Go wanted to remove that complication, and ensure Go programmers could concentrate on more productive tasks. As such, they implemented garbage collection. As a developer, this is a very good thing. Sure, garbage collection comes with its own set of issues, but those are dealt with by the language implementer while the programmer is free to reap the other many benefits of Go.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
*Go is still an experimental language subject to change.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;&amp;gt;[http://stackoverflow.com/questions/2198529/what-are-the-advantages-and-disadvantages-of-go-programming-language stackoverflow]&amp;lt;/ref&amp;gt;&lt;br /&gt;
*Go's not very usable on Windows yet.&lt;br /&gt;
*The packages distributed with Go are pretty useful, but there are still some libraries you'll miss. Most notably a UI toolkit.&lt;br /&gt;
*There is no support for generics in Go, although there are many discussions around it.&lt;br /&gt;
*Confusing Semantics Of Exported Identifiers&amp;lt;ref name = &amp;quot;Limitations2&amp;quot;&amp;gt;&lt;br /&gt;
[https://functionwhatwhat.com/go’s-type-system-is-an-embarrassment functionwhatwhat ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=88580</id>
		<title>CSC/ECE 517 Fall 2014/ch1a 10 hu</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=88580"/>
		<updated>2014-09-26T00:55:48Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Control Structures */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==''' Go Programming Language''' ==&lt;br /&gt;
'''Go''', also commonly referred to as '''golang''', is a compiled, concurrent, garbage-collected, statically typed language developed at [http://en.wikipedia.org/wiki/Google Google]. It was developed by [http://en.wikipedia.org/wiki/Robert_Griesemer Robert Griesemer], [http://en.wikipedia.org/wiki/Rob_Pike Rob Pike] and [http://en.wikipedia.org/wiki/Ken_Thompson Ken Thompson] in 2007. It was announced in November 2009 and is currently being used in many production systems at Google. It is an open source project. The syntax is loosely derived from that of [http://en.wikipedia.org/wiki/C_(programming_language) C programming language], adding [http://en.wikipedia.org/wiki/Garbage_collection_(computer_science) garbage collection], type safety, some dynamic-typing capabilities. Additional built-in types such as variable-length arrays and key-value maps, and a large standard library are also supported. Different operating systems like Linux, Microsoft Windows, Mac OS X are suported by [https://golang.org/cmd/gc Gc] compiler of Go.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
&lt;br /&gt;
Go programming started of as a research project by Robert Griesemer, Rob Pike and Ken Thompson. They felt that there was no new system focused programming language that has come up in the last decade till 2008, while there were other developments like increase in the size of libraries, dominance of networking , client server focus, multi-core CPUs.&amp;lt;ref name = &amp;quot;Background 1&amp;quot;&amp;gt;[https://www.youtube.com/watch?v=rKnDgT73v8s Go Language Introduction speech]&amp;lt;/ref&amp;gt; So they wanted to come up with a new systems focused programming language that would address the above issues.&amp;lt;ref name=&amp;quot;BG2&amp;quot;&amp;gt;[http://techcrunch.com/2009/11/10/google-go-language TechCrunch]&amp;lt;/ref&amp;gt; They started sketching the goals for a new language on the white board on September 21, 2007. Within a few days the goals had settled into a plan to do something and a fair idea of what it would be. Design continued part-time in parallel with unrelated work.&lt;br /&gt;
By January 2008, Ken had started work on a compiler with which to explore ideas; it generated C code as its output. By mid-year the language had become a full-time project and had settled enough to attempt a production compiler. In May 2008, [http://research.google.com/pubs/author37504.html Ian Taylor] independently started on a [http://en.wikipedia.org/wiki/GNU_Compiler_Collection GCC] front end for Go using the draft specification.  [http://russ.cox.usesthis.com/ Russ Cox] joined in late 2008 and helped move the language and libraries from prototype to reality.&lt;br /&gt;
Go became a public [http://en.wikipedia.org/wiki/Open_source open source project] on November 10, 2009. Many people from the community have contributed ideas, discussions, and code.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Compilers and Runtime support=&lt;br /&gt;
&lt;br /&gt;
There are two Go compiler implementations, [https://golang.org/cmd/gc Gc] (the 6g program and friends) and [http://blog.golang.org/gccgo-in-gcc-471 gccgo ]. Gc uses a different calling convention and linker. It can therefore only be linked with C programs using the same convention. Gccgo is a GCC front-end that can be linked with GCC-compiled C or C++ programs.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cgo program provides the mechanism for a “foreign function interface” to allow safe calling of C libraries from Go code. [http://en.wikipedia.org/wiki/SWIG SWIG] extends this capability to C++ libraries. &lt;br /&gt;
&lt;br /&gt;
Again due to bootstrapping issues, the run-time code is mostly in C (with a tiny bit of assembler) although Go is capable of implementing most of it now. Gccgo's run-time support uses glibc. Gc uses a custom library to keep the footprint under control; it is compiled with a version of the [http://plan9.bell-labs.com/sys/doc/compiler.html Plan 9 C compiler] that supports resizable stacks for goroutines. The gccgo compiler implements these on Linux only, using a technique called segmented stacks, supported by recent modifications to the gold linker.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find all resources needed to compile and run Go Language here http://go-lang.cat-v.org/&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
 &lt;br /&gt;
Programming today involves too much bookkeeping, repetition, and clerical work. As Dick Gabriel says, “Old programs read like quiet conversations between a well-spoken research worker and a well-studied mechanical colleague, not as a debate with a compiler. Who'd have guessed sophistication bought such noise?” The sophistication is worthwhile—no one wants to go back to the old languages—but can it be more quietly achieved?&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Go attempts to reduce the amount of typing in both senses of the word. Throughout its design, &lt;br /&gt;
*They have tried to reduce clutter and complexity. &lt;br /&gt;
*There are no forward declarations and no header files. everything is declared exactly once. &lt;br /&gt;
*Initialization is expressive, automatic, and easy to use. &lt;br /&gt;
*Syntax is clean and light on keywords. Stuttering (foo.Foo* myFoo = new(foo.Foo)) is reduced by simple type derivation using the := declare-and-initialize construct. &lt;br /&gt;
*And perhaps most radically, there is no type hierarchy. They don't have to announce their relationships.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
These simplifications allow Go to be expressive yet comprehensible without sacrificing, well, sophistication.&lt;br /&gt;
Another important principle is to keep the concepts orthogonal. Methods can be implemented for any type; structures represent data while interfaces represent abstraction; and so on. Orthogonality makes it easier to understand what happens when things combine.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Comparison between Go Programming and C++ Programming language &amp;lt;ref name=&amp;quot;KTH&amp;quot;&amp;gt;[http://www.csc.kth.se/utbildning/kth/kurser/DD143X/dkand11/Group9Alexander/Joakim_Anneback_Johan_Stjernberg.finalreport.2.pdf KTH comparison]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;quora&amp;quot;&amp;gt;[http://www.quora.com/How-does-Go-compare-to-C++-and-Java Quora comparison]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;Scriptol&amp;quot;&amp;gt;[http://www.scriptol.com/programming/go.php scriptol]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
Go programming language was developed to run as fast as C++ programs while adding a lot of other modern day features. Some of the key differeneces are listed below&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;2&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Points of Comparison&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Go Programming Language&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | C++ Programming Language&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Primary Focus'''&lt;br /&gt;
|| Go focuses on garbage collection, concurrency and compiling quickly&lt;br /&gt;
|| C++ focuses on inheritance, generic types and pointer arithmetics.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Variable Sizes'''&lt;br /&gt;
|| Machine-independent types are now included without an import needed:  int8, int16, int32, int64, uint8, etc.&lt;br /&gt;
|| Machine-dependent variable sizes&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Class Hierarchies'''&lt;br /&gt;
|| Inheritance is not supported , but with the traditional structures with plain old functions and namespaces, is a MUCH &lt;br /&gt;
better, more flexible approach that leads to better, more maintainable code. &lt;br /&gt;
|| Inheritance is supported but it has its own share of problems like diamond inheritance, virtual inheritance and normal inheritance.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Function overloading'''&lt;br /&gt;
|| Not present in Go because it simplifies dispatch.	&lt;br /&gt;
|| Present in C++.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Genrics'''&lt;br /&gt;
|| Go does not currently support generic types. However, it does support objects without a type using the empty interface.&lt;br /&gt;
|| C++ on the other hand has support for generic types. Generic programming is supported by the use of function templates, class templates and, in some cases, specialized templates in C++.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Multithreading'''&lt;br /&gt;
|| Goroutines are Go's model of threads/coroutines. Each new goroutine runs in parallel with the current computation, in &amp;quot;the same address space. Goroutines are cheap and developers need not to &lt;br /&gt;
worry about the stack size.&lt;br /&gt;
|| In contrast, there is currently no built-in way to manage threads in C++, although the feature is expected in the upcoming new standard and is already today possible using third-party libraries. &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Garbage Collection'''&lt;br /&gt;
|| Go uses garbage collection for memory management, which means that if frees the programmer completely from keeping a track on the memory used.&lt;br /&gt;
|| C++ does not have any garbage collection and hence relies heavily on that the programmer knows what he or she is doing.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Language Design&amp;lt;ref name = &amp;quot;GoLang Book&amp;quot;&amp;gt;[http://www.golang-book.com, GoLang Book]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 package main //line 1&lt;br /&gt;
&lt;br /&gt;
   import “fmt”  //line 2&lt;br /&gt;
&lt;br /&gt;
   func main() {  //line 3&lt;br /&gt;
&lt;br /&gt;
       fmt.Println(“Hello World”) //line 4&lt;br /&gt;
&lt;br /&gt;
   } //line 5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The program above depicts the basic syntax of a program written using Go. Line1 specifies package declaration. Package is used to organize and reuse code. Line 2 is used for including the package “fmt” which is used for formatting input and output. Line 3 to 5 defines the function main. main is the function which is called when a program is executed. Println function in fmt is used to display content to the console i.e in this example Hello World is displayed in the console on executing the program.&lt;br /&gt;
&lt;br /&gt;
==Code Conventions and Style==&lt;br /&gt;
&lt;br /&gt;
* Go fmt tool is used to automatically standardize indentation, spaces and surface-level code details (go vet and go link perform checking automatically).&lt;br /&gt;
* Using tools and libraries provided in Go, there are standard approaches for API documentation (go doc), testing (go test), building( go build) and package management(go get).&lt;br /&gt;
* Syntax prevents any kind of cyclic dependencies.&lt;br /&gt;
* Unused variables and imports are not allowed.&lt;br /&gt;
* Elimination of functional programming constructs (such as map and try/finally) ensure a concrete and explicit programming style.&lt;br /&gt;
&lt;br /&gt;
==Types==&lt;br /&gt;
&lt;br /&gt;
* Numbers are represented in Go as either Integers or Floating point numbers.&lt;br /&gt;
**Integers: Used to represent numbers without a decimal component. Different integers supported by Go are: uint8, uint16, uint32, uint64, int8, int16, int32, int64. Uint is used for unsigned integers and int for signed. 8,16, 32, 64 indicate the number of bits each type would use.&lt;br /&gt;
**Floating Point Integers: Used to support decimal components. Go supports float32 and float64 to represent floating point numbers and complex32 and complex64 to represent complex numbers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var x int32 =4&lt;br /&gt;
var y float32 = 4.5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* String: String literals can be created using either double quotes(“Hello”) or back ticks(`Hello`). Strings have several operations associated them, for example one can find the length of the string or get a character at a specific index in a string. Example below illustrates these functions.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
	fmt.Println(len(“Hello”)) // output: 5&lt;br /&gt;
	fmt.Println(“Hello”[1]) // output: e&lt;br /&gt;
	fmt.Println(“Hello “+”Tom”) //output: Hello Tom&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Boolean: A 1 bit value is used to represent true or false.&lt;br /&gt;
&lt;br /&gt;
==Variables and Constants==&lt;br /&gt;
*Variabes in Go are indicated using the var keyword. Example: var x string=”hello” . They can also be shorthanded as x:=”hello” .&lt;br /&gt;
*The variable names should begin with a letter and can contain letters, digits or underscore character.&lt;br /&gt;
*The scope of the variable is the block in which it is defined and an attempt to access it outside the block would result in an error on running the program.&lt;br /&gt;
*Go provides support for constants (i.e. variables whose value can not be changed), using the const keyword. Example: const temp string = “Hello”&lt;br /&gt;
*In Go one can define multiple variables(or constants) using the following syntax:&lt;br /&gt;
    var(&lt;br /&gt;
         t1 =1&lt;br /&gt;
         t2=2&lt;br /&gt;
         t3=3&lt;br /&gt;
        t4=4&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Control Structures==&lt;br /&gt;
*For: It is used for repeating a list of statement(s) multiple times. The example below is used for calculating sum of numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    i := 1&lt;br /&gt;
    sum := 0&lt;br /&gt;
&lt;br /&gt;
    for i &amp;lt;= 10 {&lt;br /&gt;
        sum = sum + i&lt;br /&gt;
        i = i + 1&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    fmt.Println(“Sum:” + sum)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the example above i is a loop counter variable and is used to ensure that sum of numbers from 1 to 10 is computed. It indicates the number of times the statements inside the for loop are to be executed. The statement following the keyword for should evaluate to either true or false. If it is evaluated to true the body of for is executed, else we come out of the for loop.&lt;br /&gt;
&lt;br /&gt;
*If: Used to execute a block of statement(s) based on the evaluation of an expression to either true or false. It can also have an else associated with it.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    if i % 2 == 0 {&lt;br /&gt;
        fmt.Println(i + ” is divisble by 2”)&lt;br /&gt;
    } else {&lt;br /&gt;
        fmt.Println(i + “is not divisible by 2”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Switch: The value of the expression following switch is evaluated and is compared against the different cases. Based on the matching case, the block following that case is executed. Switch also has a default case in situations when none of the cases are matching.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    // if op ==1 then so a+b&lt;br /&gt;
    // if op == 2 then do a-b&lt;br /&gt;
    // if op == 3 then do a*b&lt;br /&gt;
    // if op ==4 then do a/b&lt;br /&gt;
    // default print, invalid operator&lt;br /&gt;
&lt;br /&gt;
    op:= 1&lt;br /&gt;
    a=6&lt;br /&gt;
    b=7&lt;br /&gt;
    switch(op) {&lt;br /&gt;
        case 1: fmt.Println(a+b)&lt;br /&gt;
        case 2: fmt.Println(a-b)&lt;br /&gt;
        case 3: fmt.Println(a*b)&lt;br /&gt;
        case 4: fmt.Println(a/b)&lt;br /&gt;
        default: fmt.Println(“Invalid Operator”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Arrays, Slices and Maps==&lt;br /&gt;
&lt;br /&gt;
*Arrays: Numbered sequence of elements starting with index zero and each of the elements having a fixed length. The example below illustrates various operations performed on arrays in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
    var x[10] int&lt;br /&gt;
    x[99]=100&lt;br /&gt;
    fmt.Println(x)  //[0 0 ….. 0 100]&lt;br /&gt;
    fmt.Println(len(x)) //100&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Slices: &lt;br /&gt;
** It is a segment of an array.&lt;br /&gt;
** They have a length and are indexable.&lt;br /&gt;
**In case of a slice the size does not have to specified in the square bracket.&lt;br /&gt;
**Slices support two in-build functions: copy and append.&lt;br /&gt;
**The program below illustrates the different ways to create slices and use of copy and append.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    arr := [10] int {1,2,3,4,5,6,7,8,9,10}&lt;br /&gt;
    x := make([]int,10) // creates a slice [1...10]&lt;br /&gt;
    y := make([]int,10,10) //creates a slice [1...10]&lt;br /&gt;
    z := arr[0:10] //creates a slice [1...10]&lt;br /&gt;
    s1 := []int{1,2,3,4,5}&lt;br /&gt;
    s2 := append(s1, 6, 7)&lt;br /&gt;
    fmt.Println(s1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(s2) // [1,2,3,4,5,6,7]&lt;br /&gt;
    p1 := [] int{1,2,3,4,5}&lt;br /&gt;
    p2 :=make([]int, 4)&lt;br /&gt;
    copy(p2,p1)&lt;br /&gt;
    fmt.Println(p1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(p2)// [1,2,3,4]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Maps:&lt;br /&gt;
**A map is an unordered collection of key value pairs.&lt;br /&gt;
**Syntax: var x map[int] string , where int is the type of the key and string is the type of the value.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
    x := make(map[int]string)&lt;br /&gt;
    x[1] = one&lt;br /&gt;
    x[2] = two&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
&lt;br /&gt;
*In Go functions can take multiple inputs and return multiple outputs.&lt;br /&gt;
*Go supports a special kind of function called variadic function.&lt;br /&gt;
*Closure is the means by which functions can be created inside other function in Go.&lt;br /&gt;
*Go supports recursive functions.&lt;br /&gt;
*The example below the different types of function in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    display(“Hello World”)&lt;br /&gt;
    sum :=calculateSum(10,20)&lt;br /&gt;
    v1,v2=multipleValues()&lt;br /&gt;
    p=product(5,10,20)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function without return type&lt;br /&gt;
func display( s string) {&lt;br /&gt;
    fmt.Println(s)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns a single value&lt;br /&gt;
func calculateSum(a int, b int) int {&lt;br /&gt;
    c: = a + b&lt;br /&gt;
    return c&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns multiple values&lt;br /&gt;
func multipleValues(int, int) {&lt;br /&gt;
    return 1, 2&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Variadic function&lt;br /&gt;
func product(args ...int) int {&lt;br /&gt;
    p := 1&lt;br /&gt;
   for _, i := range args {&lt;br /&gt;
        p *= i&lt;br /&gt;
   }&lt;br /&gt;
   return p&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pointers==&lt;br /&gt;
It is used to reference a location in the memory where the value is stored rather than containing the value itself. Basic pointer operations in Go are illustrated in the example below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
//Different syntax for pointers&lt;br /&gt;
    &lt;br /&gt;
     ptr1 *int&lt;br /&gt;
     num :=10&lt;br /&gt;
     ptr1 = &amp;amp;num&lt;br /&gt;
     ptr2 := new(int)&lt;br /&gt;
     ptr2=&amp;amp;num&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Concurrency==&lt;br /&gt;
* Go ensures concurrency which allows sharing of state using communication mechanisms.&lt;br /&gt;
* Go provides support for multithreading and CPU parallelization.&lt;br /&gt;
* Go supports asynchrony i.e. allows operations like database and network I/O which are slow operations to occur in parallel along with other operations.&lt;br /&gt;
* A new lightweight process is created using go fund()&lt;br /&gt;
* Channel types are used for providing type safe and synchronized channels between different go routines.&lt;br /&gt;
&lt;br /&gt;
=Users of Go=&lt;br /&gt;
Apart from Google, which uses Go programming for some of its development, companies like [http://en.wikipedia.org/wiki/Dropbox_(service) Dropbox], [http://en.wikipedia.org/wiki/CloudFlare CloudFlare], [http://en.wikipedia.org/wiki/SoundCloud SoundCloud], The BBC, Novartis, Cloud Foundry also use Go programming.  &lt;br /&gt;
Dropbox server (running in the cloud) and desktop client software were primarily written in [http://en.wikipedia.org/wiki/Python_(programming_language) Python]. From mid-2013 Dropbox began migrating its backend infrastructure to Go.&lt;br /&gt;
Some of the open-source applications that are using Go programming are Docker, Flynn, PaaS, Juju, nsq, Doozer e.t.c .&amp;lt;ref name = &amp;quot;GoWIKI&amp;quot;&amp;gt;[http://en.wikipedia.org/wiki/Go_(programming_language), Wikipedia]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advantages&amp;lt;ref name=&amp;quot;csdn&amp;quot;&amp;gt; [http://blog.csdn.net/lymemoryzz/article/details/20960997 CSDN blog]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
 &lt;br /&gt;
*'''C Level Performance'''. golang is within a close margin of the performance level of C code (which is itself an extremely high performance language). It is certainly closer to the performance of native languages than other enterprise level languages such as Java, Scala, Erlang etc.&lt;br /&gt;
 &lt;br /&gt;
*'''Fast Compilation''' is one of the key advantages of Go language. The Golang compiler was designed to compile programs very quickly. Extremely large programs with massively high LOC counts compile seemingly instantly - after all, Golang was designed by Google to solve Google problems, and Google has big problems! At Google, code and CPU cores are both measured in the millions. Go provides a model for software construction that makes dependency analysis easy and avoids much of the overhead of C-style include files and libraries.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reduced compile time is a key improvement in the Go language&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      If A.go depends on B.go depends on C.go :&lt;br /&gt;
         Compile C.go, B.go then A.go normally (other languages)&lt;br /&gt;
         To compile A.go, compiler reads B.o not C.o (go)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At a large scale this should help in hugely speeding up&lt;br /&gt;
&lt;br /&gt;
Other advantages are      &lt;br /&gt;
* '''Concurrency Supported At Language Level'''. Concurrency is the ability to execute multiple computations simultaneously. In today's modern multicore and high-load computing environment, concurrency is a critical language feature, and one in which languages such as Java struggle immensely.&lt;br /&gt;
* By its design, Go proposes an approach for the construction of system software on '''multicore machines'''.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
* Google have summed things up nicely with their motto: '''Don't communicate by sharing memory, share memory by communicating'''.Channels allow you to pass references to data structures between goroutines. If you consider this as passing around ownership of the data (the ability to read and write it), they become a powerful and expressive synchronization mechanism.  &lt;br /&gt;
* '''Go's type system has no hierarchy''', so no time is spent defining the relationships between types. Also, although Go has static types, the language attempts to make types feel lighter weight than in typical Object Oriented languages.&lt;br /&gt;
* '''Garbage Collection is much better'''. In C and C++, programmers spend a lot of time and energy on allocating and freeing memory. The designers of Go wanted to remove that complication, and ensure Go programmers could concentrate on more productive tasks. As such, they implemented garbage collection. As a developer, this is a very good thing. Sure, garbage collection comes with its own set of issues, but those are dealt with by the language implementer while the programmer is free to reap the other many benefits of Go.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
*Go is still an experimental language subject to change.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;&amp;gt;[http://stackoverflow.com/questions/2198529/what-are-the-advantages-and-disadvantages-of-go-programming-language stackoverflow]&amp;lt;/ref&amp;gt;&lt;br /&gt;
*Go's not very usable on Windows yet.&lt;br /&gt;
*The packages distributed with Go are pretty useful, but there are still some libraries you'll miss. Most notably a UI toolkit.&lt;br /&gt;
*There is no support for generics in Go, although there are many discussions around it.&lt;br /&gt;
*Confusing Semantics Of Exported Identifiers&amp;lt;ref name = &amp;quot;Limitations2&amp;quot;&amp;gt;&lt;br /&gt;
[https://functionwhatwhat.com/go’s-type-system-is-an-embarrassment functionwhatwhat ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=88578</id>
		<title>CSC/ECE 517 Fall 2014/ch1a 10 hu</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=88578"/>
		<updated>2014-09-26T00:53:48Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Types */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==''' Go Programming Language''' ==&lt;br /&gt;
'''Go''', also commonly referred to as '''golang''', is a compiled, concurrent, garbage-collected, statically typed language developed at [http://en.wikipedia.org/wiki/Google Google]. It was developed by [http://en.wikipedia.org/wiki/Robert_Griesemer Robert Griesemer], [http://en.wikipedia.org/wiki/Rob_Pike Rob Pike] and [http://en.wikipedia.org/wiki/Ken_Thompson Ken Thompson] in 2007. It was announced in November 2009 and is currently being used in many production systems at Google. It is an open source project. The syntax is loosely derived from that of [http://en.wikipedia.org/wiki/C_(programming_language) C programming language], adding [http://en.wikipedia.org/wiki/Garbage_collection_(computer_science) garbage collection], type safety, some dynamic-typing capabilities. Additional built-in types such as variable-length arrays and key-value maps, and a large standard library are also supported. Different operating systems like Linux, Microsoft Windows, Mac OS X are suported by [https://golang.org/cmd/gc Gc] compiler of Go.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
&lt;br /&gt;
Go programming started of as a research project by Robert Griesemer, Rob Pike and Ken Thompson. They felt that there was no new system focused programming language that has come up in the last decade till 2008, while there were other developments like increase in the size of libraries, dominance of networking , client server focus, multi-core CPUs.&amp;lt;ref name = &amp;quot;Background 1&amp;quot;&amp;gt;[https://www.youtube.com/watch?v=rKnDgT73v8s Go Language Introduction speech]&amp;lt;/ref&amp;gt; So they wanted to come up with a new systems focused programming language that would address the above issues.&amp;lt;ref name=&amp;quot;BG2&amp;quot;&amp;gt;[http://techcrunch.com/2009/11/10/google-go-language TechCrunch]&amp;lt;/ref&amp;gt; They started sketching the goals for a new language on the white board on September 21, 2007. Within a few days the goals had settled into a plan to do something and a fair idea of what it would be. Design continued part-time in parallel with unrelated work.&lt;br /&gt;
By January 2008, Ken had started work on a compiler with which to explore ideas; it generated C code as its output. By mid-year the language had become a full-time project and had settled enough to attempt a production compiler. In May 2008, [http://research.google.com/pubs/author37504.html Ian Taylor] independently started on a [http://en.wikipedia.org/wiki/GNU_Compiler_Collection GCC] front end for Go using the draft specification.  [http://russ.cox.usesthis.com/ Russ Cox] joined in late 2008 and helped move the language and libraries from prototype to reality.&lt;br /&gt;
Go became a public [http://en.wikipedia.org/wiki/Open_source open source project] on November 10, 2009. Many people from the community have contributed ideas, discussions, and code.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Compilers and Runtime support=&lt;br /&gt;
&lt;br /&gt;
There are two Go compiler implementations, [https://golang.org/cmd/gc Gc] (the 6g program and friends) and [http://blog.golang.org/gccgo-in-gcc-471 gccgo ]. Gc uses a different calling convention and linker. It can therefore only be linked with C programs using the same convention. Gccgo is a GCC front-end that can be linked with GCC-compiled C or C++ programs.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cgo program provides the mechanism for a “foreign function interface” to allow safe calling of C libraries from Go code. [http://en.wikipedia.org/wiki/SWIG SWIG] extends this capability to C++ libraries. &lt;br /&gt;
&lt;br /&gt;
Again due to bootstrapping issues, the run-time code is mostly in C (with a tiny bit of assembler) although Go is capable of implementing most of it now. Gccgo's run-time support uses glibc. Gc uses a custom library to keep the footprint under control; it is compiled with a version of the [http://plan9.bell-labs.com/sys/doc/compiler.html Plan 9 C compiler] that supports resizable stacks for goroutines. The gccgo compiler implements these on Linux only, using a technique called segmented stacks, supported by recent modifications to the gold linker.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find all resources needed to compile and run Go Language here http://go-lang.cat-v.org/&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
 &lt;br /&gt;
Programming today involves too much bookkeeping, repetition, and clerical work. As Dick Gabriel says, “Old programs read like quiet conversations between a well-spoken research worker and a well-studied mechanical colleague, not as a debate with a compiler. Who'd have guessed sophistication bought such noise?” The sophistication is worthwhile—no one wants to go back to the old languages—but can it be more quietly achieved?&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Go attempts to reduce the amount of typing in both senses of the word. Throughout its design, &lt;br /&gt;
*They have tried to reduce clutter and complexity. &lt;br /&gt;
*There are no forward declarations and no header files. everything is declared exactly once. &lt;br /&gt;
*Initialization is expressive, automatic, and easy to use. &lt;br /&gt;
*Syntax is clean and light on keywords. Stuttering (foo.Foo* myFoo = new(foo.Foo)) is reduced by simple type derivation using the := declare-and-initialize construct. &lt;br /&gt;
*And perhaps most radically, there is no type hierarchy. They don't have to announce their relationships.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
These simplifications allow Go to be expressive yet comprehensible without sacrificing, well, sophistication.&lt;br /&gt;
Another important principle is to keep the concepts orthogonal. Methods can be implemented for any type; structures represent data while interfaces represent abstraction; and so on. Orthogonality makes it easier to understand what happens when things combine.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Comparison between Go Programming and C++ Programming language &amp;lt;ref name=&amp;quot;KTH&amp;quot;&amp;gt;[http://www.csc.kth.se/utbildning/kth/kurser/DD143X/dkand11/Group9Alexander/Joakim_Anneback_Johan_Stjernberg.finalreport.2.pdf KTH comparison]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;quora&amp;quot;&amp;gt;[http://www.quora.com/How-does-Go-compare-to-C++-and-Java Quora comparison]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;Scriptol&amp;quot;&amp;gt;[http://www.scriptol.com/programming/go.php scriptol]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
Go programming language was developed to run as fast as C++ programs while adding a lot of other modern day features. Some of the key differeneces are listed below&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;2&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Points of Comparison&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Go Programming Language&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | C++ Programming Language&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Primary Focus'''&lt;br /&gt;
|| Go focuses on garbage collection, concurrency and compiling quickly&lt;br /&gt;
|| C++ focuses on inheritance, generic types and pointer arithmetics.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Variable Sizes'''&lt;br /&gt;
|| Machine-independent types are now included without an import needed:  int8, int16, int32, int64, uint8, etc.&lt;br /&gt;
|| Machine-dependent variable sizes&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Class Hierarchies'''&lt;br /&gt;
|| Inheritance is not supported , but with the traditional structures with plain old functions and namespaces, is a MUCH &lt;br /&gt;
better, more flexible approach that leads to better, more maintainable code. &lt;br /&gt;
|| Inheritance is supported but it has its own share of problems like diamond inheritance, virtual inheritance and normal inheritance.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Function overloading'''&lt;br /&gt;
|| Not present in Go because it simplifies dispatch.	&lt;br /&gt;
|| Present in C++.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Genrics'''&lt;br /&gt;
|| Go does not currently support generic types. However, it does support objects without a type using the empty interface.&lt;br /&gt;
|| C++ on the other hand has support for generic types. Generic programming is supported by the use of function templates, class templates and, in some cases, specialized templates in C++.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Multithreading'''&lt;br /&gt;
|| Goroutines are Go's model of threads/coroutines. Each new goroutine runs in parallel with the current computation, in &amp;quot;the same address space. Goroutines are cheap and developers need not to &lt;br /&gt;
worry about the stack size.&lt;br /&gt;
|| In contrast, there is currently no built-in way to manage threads in C++, although the feature is expected in the upcoming new standard and is already today possible using third-party libraries. &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Garbage Collection'''&lt;br /&gt;
|| Go uses garbage collection for memory management, which means that if frees the programmer completely from keeping a track on the memory used.&lt;br /&gt;
|| C++ does not have any garbage collection and hence relies heavily on that the programmer knows what he or she is doing.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Language Design&amp;lt;ref name = &amp;quot;GoLang Book&amp;quot;&amp;gt;[http://www.golang-book.com, GoLang Book]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 package main //line 1&lt;br /&gt;
&lt;br /&gt;
   import “fmt”  //line 2&lt;br /&gt;
&lt;br /&gt;
   func main() {  //line 3&lt;br /&gt;
&lt;br /&gt;
       fmt.Println(“Hello World”) //line 4&lt;br /&gt;
&lt;br /&gt;
   } //line 5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The program above depicts the basic syntax of a program written using Go. Line1 specifies package declaration. Package is used to organize and reuse code. Line 2 is used for including the package “fmt” which is used for formatting input and output. Line 3 to 5 defines the function main. main is the function which is called when a program is executed. Println function in fmt is used to display content to the console i.e in this example Hello World is displayed in the console on executing the program.&lt;br /&gt;
&lt;br /&gt;
==Code Conventions and Style==&lt;br /&gt;
&lt;br /&gt;
* Go fmt tool is used to automatically standardize indentation, spaces and surface-level code details (go vet and go link perform checking automatically).&lt;br /&gt;
* Using tools and libraries provided in Go, there are standard approaches for API documentation (go doc), testing (go test), building( go build) and package management(go get).&lt;br /&gt;
* Syntax prevents any kind of cyclic dependencies.&lt;br /&gt;
* Unused variables and imports are not allowed.&lt;br /&gt;
* Elimination of functional programming constructs (such as map and try/finally) ensure a concrete and explicit programming style.&lt;br /&gt;
&lt;br /&gt;
==Types==&lt;br /&gt;
&lt;br /&gt;
* Numbers are represented in Go as either Integers or Floating point numbers.&lt;br /&gt;
**Integers: Used to represent numbers without a decimal component. Different integers supported by Go are: uint8, uint16, uint32, uint64, int8, int16, int32, int64. Uint is used for unsigned integers and int for signed. 8,16, 32, 64 indicate the number of bits each type would use.&lt;br /&gt;
**Floating Point Integers: Used to support decimal components. Go supports float32 and float64 to represent floating point numbers and complex32 and complex64 to represent complex numbers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var x int32 =4&lt;br /&gt;
var y float32 = 4.5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* String: String literals can be created using either double quotes(“Hello”) or back ticks(`Hello`). Strings have several operations associated them, for example one can find the length of the string or get a character at a specific index in a string. Example below illustrates these functions.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
	fmt.Println(len(“Hello”)) // output: 5&lt;br /&gt;
	fmt.Println(“Hello”[1]) // output: e&lt;br /&gt;
	fmt.Println(“Hello “+”Tom”) //output: Hello Tom&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Boolean: A 1 bit value is used to represent true or false.&lt;br /&gt;
&lt;br /&gt;
==Variables and Constants==&lt;br /&gt;
*Variabes in Go are indicated using the var keyword. Example: var x string=”hello” . They can also be shorthanded as x:=”hello” .&lt;br /&gt;
*The variable names should begin with a letter and can contain letters, digits or underscore character.&lt;br /&gt;
*The scope of the variable is the block in which it is defined and an attempt to access it outside the block would result in an error on running the program.&lt;br /&gt;
*Go provides support for constants (i.e. variables whose value can not be changed), using the const keyword. Example: const temp string = “Hello”&lt;br /&gt;
*In Go one can define multiple variables(or constants) using the following syntax:&lt;br /&gt;
    var(&lt;br /&gt;
         t1 =1&lt;br /&gt;
         t2=2&lt;br /&gt;
         t3=3&lt;br /&gt;
        t4=4&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Control Structures==&lt;br /&gt;
*For: It is used for repeating a list of statement(s) multiple times. The example below is used for calculating sum of numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    i := 1&lt;br /&gt;
    sum := 0&lt;br /&gt;
&lt;br /&gt;
    for i &amp;lt;= 10 {&lt;br /&gt;
        sum = sum + i&lt;br /&gt;
        i = i + 1&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    fmt.Println(“Sum:” + sum)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the example above i is a loop counter variable and is used to ensure that sum of numbers from 1 to 10 is computed. It indicates the number of times the statements inside the for loop is to be executed. The statement following the keyword for should evaluate to either true or false. If it is evaluated to true the body of for is executed, else we come out of the for loop.&lt;br /&gt;
&lt;br /&gt;
*If: Used to execute a block of statement(s) based on the evaluation of an expression to either true or false. It can also have an else associated with it.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    if i % 2 == 0 {&lt;br /&gt;
        fmt.Println(i + ” is divisble by 2”)&lt;br /&gt;
    } else {&lt;br /&gt;
        fmt.Println(i + “is not divisible by 2”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Switch: The value of the expression following switch is evaluated and is compared against the different cases. Based on the matching case, the block following that case is executed. Switch also has a default case in situations when none of the cases are matching.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    // if op ==1 then so a+b&lt;br /&gt;
    // if op == 2 then do a-b&lt;br /&gt;
    // if op == 3 then do a*b&lt;br /&gt;
    // if op ==4 then do a/b&lt;br /&gt;
    // default print, invalid operator&lt;br /&gt;
&lt;br /&gt;
    op:= 1&lt;br /&gt;
    a=6&lt;br /&gt;
    b=7&lt;br /&gt;
    switch(op) {&lt;br /&gt;
        case 1: fmt.Println(a+b)&lt;br /&gt;
        case 2: fmt.Println(a-b)&lt;br /&gt;
        case 3: fmt.Println(a*b)&lt;br /&gt;
        case 4: fmt.Println(a/b)&lt;br /&gt;
        default: fmt.Println(“Invalid Operator”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Arrays, Slices and Maps==&lt;br /&gt;
&lt;br /&gt;
*Arrays: Numbered sequence of elements starting with index zero and each of the elements having a fixed length. The example below illustrates various operations performed on arrays in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
    var x[10] int&lt;br /&gt;
    x[99]=100&lt;br /&gt;
    fmt.Println(x)  //[0 0 ….. 0 100]&lt;br /&gt;
    fmt.Println(len(x)) //100&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Slices: &lt;br /&gt;
** It is a segment of an array.&lt;br /&gt;
** They have a length and are indexable.&lt;br /&gt;
**In case of a slice the size does not have to specified in the square bracket.&lt;br /&gt;
**Slices support two in-build functions: copy and append.&lt;br /&gt;
**The program below illustrates the different ways to create slices and use of copy and append.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    arr := [10] int {1,2,3,4,5,6,7,8,9,10}&lt;br /&gt;
    x := make([]int,10) // creates a slice [1...10]&lt;br /&gt;
    y := make([]int,10,10) //creates a slice [1...10]&lt;br /&gt;
    z := arr[0:10] //creates a slice [1...10]&lt;br /&gt;
    s1 := []int{1,2,3,4,5}&lt;br /&gt;
    s2 := append(s1, 6, 7)&lt;br /&gt;
    fmt.Println(s1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(s2) // [1,2,3,4,5,6,7]&lt;br /&gt;
    p1 := [] int{1,2,3,4,5}&lt;br /&gt;
    p2 :=make([]int, 4)&lt;br /&gt;
    copy(p2,p1)&lt;br /&gt;
    fmt.Println(p1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(p2)// [1,2,3,4]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Maps:&lt;br /&gt;
**A map is an unordered collection of key value pairs.&lt;br /&gt;
**Syntax: var x map[int] string , where int is the type of the key and string is the type of the value.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
    x := make(map[int]string)&lt;br /&gt;
    x[1] = one&lt;br /&gt;
    x[2] = two&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
&lt;br /&gt;
*In Go functions can take multiple inputs and return multiple outputs.&lt;br /&gt;
*Go supports a special kind of function called variadic function.&lt;br /&gt;
*Closure is the means by which functions can be created inside other function in Go.&lt;br /&gt;
*Go supports recursive functions.&lt;br /&gt;
*The example below the different types of function in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    display(“Hello World”)&lt;br /&gt;
    sum :=calculateSum(10,20)&lt;br /&gt;
    v1,v2=multipleValues()&lt;br /&gt;
    p=product(5,10,20)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function without return type&lt;br /&gt;
func display( s string) {&lt;br /&gt;
    fmt.Println(s)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns a single value&lt;br /&gt;
func calculateSum(a int, b int) int {&lt;br /&gt;
    c: = a + b&lt;br /&gt;
    return c&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns multiple values&lt;br /&gt;
func multipleValues(int, int) {&lt;br /&gt;
    return 1, 2&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Variadic function&lt;br /&gt;
func product(args ...int) int {&lt;br /&gt;
    p := 1&lt;br /&gt;
   for _, i := range args {&lt;br /&gt;
        p *= i&lt;br /&gt;
   }&lt;br /&gt;
   return p&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pointers==&lt;br /&gt;
It is used to reference a location in the memory where the value is stored rather than containing the value itself. Basic pointer operations in Go are illustrated in the example below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
//Different syntax for pointers&lt;br /&gt;
    &lt;br /&gt;
     ptr1 *int&lt;br /&gt;
     num :=10&lt;br /&gt;
     ptr1 = &amp;amp;num&lt;br /&gt;
     ptr2 := new(int)&lt;br /&gt;
     ptr2=&amp;amp;num&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Concurrency==&lt;br /&gt;
* Go ensures concurrency which allows sharing of state using communication mechanisms.&lt;br /&gt;
* Go provides support for multithreading and CPU parallelization.&lt;br /&gt;
* Go supports asynchrony i.e. allows operations like database and network I/O which are slow operations to occur in parallel along with other operations.&lt;br /&gt;
* A new lightweight process is created using go fund()&lt;br /&gt;
* Channel types are used for providing type safe and synchronized channels between different go routines.&lt;br /&gt;
&lt;br /&gt;
=Users of Go=&lt;br /&gt;
Apart from Google, which uses Go programming for some of its development, companies like [http://en.wikipedia.org/wiki/Dropbox_(service) Dropbox], [http://en.wikipedia.org/wiki/CloudFlare CloudFlare], [http://en.wikipedia.org/wiki/SoundCloud SoundCloud], The BBC, Novartis, Cloud Foundry also use Go programming.  &lt;br /&gt;
Dropbox server (running in the cloud) and desktop client software were primarily written in [http://en.wikipedia.org/wiki/Python_(programming_language) Python]. From mid-2013 Dropbox began migrating its backend infrastructure to Go.&lt;br /&gt;
Some of the open-source applications that are using Go programming are Docker, Flynn, PaaS, Juju, nsq, Doozer e.t.c .&amp;lt;ref name = &amp;quot;GoWIKI&amp;quot;&amp;gt;[http://en.wikipedia.org/wiki/Go_(programming_language), Wikipedia]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advantages&amp;lt;ref name=&amp;quot;csdn&amp;quot;&amp;gt; [http://blog.csdn.net/lymemoryzz/article/details/20960997 CSDN blog]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
 &lt;br /&gt;
*'''C Level Performance'''. golang is within a close margin of the performance level of C code (which is itself an extremely high performance language). It is certainly closer to the performance of native languages than other enterprise level languages such as Java, Scala, Erlang etc.&lt;br /&gt;
 &lt;br /&gt;
*'''Fast Compilation''' is one of the key advantages of Go language. The Golang compiler was designed to compile programs very quickly. Extremely large programs with massively high LOC counts compile seemingly instantly - after all, Golang was designed by Google to solve Google problems, and Google has big problems! At Google, code and CPU cores are both measured in the millions. Go provides a model for software construction that makes dependency analysis easy and avoids much of the overhead of C-style include files and libraries.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reduced compile time is a key improvement in the Go language&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      If A.go depends on B.go depends on C.go :&lt;br /&gt;
         Compile C.go, B.go then A.go normally (other languages)&lt;br /&gt;
         To compile A.go, compiler reads B.o not C.o (go)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At a large scale this should help in hugely speeding up&lt;br /&gt;
&lt;br /&gt;
Other advantages are      &lt;br /&gt;
* '''Concurrency Supported At Language Level'''. Concurrency is the ability to execute multiple computations simultaneously. In today's modern multicore and high-load computing environment, concurrency is a critical language feature, and one in which languages such as Java struggle immensely.&lt;br /&gt;
* By its design, Go proposes an approach for the construction of system software on '''multicore machines'''.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
* Google have summed things up nicely with their motto: '''Don't communicate by sharing memory, share memory by communicating'''.Channels allow you to pass references to data structures between goroutines. If you consider this as passing around ownership of the data (the ability to read and write it), they become a powerful and expressive synchronization mechanism.  &lt;br /&gt;
* '''Go's type system has no hierarchy''', so no time is spent defining the relationships between types. Also, although Go has static types, the language attempts to make types feel lighter weight than in typical Object Oriented languages.&lt;br /&gt;
* '''Garbage Collection is much better'''. In C and C++, programmers spend a lot of time and energy on allocating and freeing memory. The designers of Go wanted to remove that complication, and ensure Go programmers could concentrate on more productive tasks. As such, they implemented garbage collection. As a developer, this is a very good thing. Sure, garbage collection comes with its own set of issues, but those are dealt with by the language implementer while the programmer is free to reap the other many benefits of Go.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
*Go is still an experimental language subject to change.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;&amp;gt;[http://stackoverflow.com/questions/2198529/what-are-the-advantages-and-disadvantages-of-go-programming-language stackoverflow]&amp;lt;/ref&amp;gt;&lt;br /&gt;
*Go's not very usable on Windows yet.&lt;br /&gt;
*The packages distributed with Go are pretty useful, but there are still some libraries you'll miss. Most notably a UI toolkit.&lt;br /&gt;
*There is no support for generics in Go, although there are many discussions around it.&lt;br /&gt;
*Confusing Semantics Of Exported Identifiers&amp;lt;ref name = &amp;quot;Limitations2&amp;quot;&amp;gt;&lt;br /&gt;
[https://functionwhatwhat.com/go’s-type-system-is-an-embarrassment functionwhatwhat ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=88577</id>
		<title>CSC/ECE 517 Fall 2014/ch1a 10 hu</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=88577"/>
		<updated>2014-09-26T00:53:01Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Types */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==''' Go Programming Language''' ==&lt;br /&gt;
'''Go''', also commonly referred to as '''golang''', is a compiled, concurrent, garbage-collected, statically typed language developed at [http://en.wikipedia.org/wiki/Google Google]. It was developed by [http://en.wikipedia.org/wiki/Robert_Griesemer Robert Griesemer], [http://en.wikipedia.org/wiki/Rob_Pike Rob Pike] and [http://en.wikipedia.org/wiki/Ken_Thompson Ken Thompson] in 2007. It was announced in November 2009 and is currently being used in many production systems at Google. It is an open source project. The syntax is loosely derived from that of [http://en.wikipedia.org/wiki/C_(programming_language) C programming language], adding [http://en.wikipedia.org/wiki/Garbage_collection_(computer_science) garbage collection], type safety, some dynamic-typing capabilities. Additional built-in types such as variable-length arrays and key-value maps, and a large standard library are also supported. Different operating systems like Linux, Microsoft Windows, Mac OS X are suported by [https://golang.org/cmd/gc Gc] compiler of Go.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
&lt;br /&gt;
Go programming started of as a research project by Robert Griesemer, Rob Pike and Ken Thompson. They felt that there was no new system focused programming language that has come up in the last decade till 2008, while there were other developments like increase in the size of libraries, dominance of networking , client server focus, multi-core CPUs.&amp;lt;ref name = &amp;quot;Background 1&amp;quot;&amp;gt;[https://www.youtube.com/watch?v=rKnDgT73v8s Go Language Introduction speech]&amp;lt;/ref&amp;gt; So they wanted to come up with a new systems focused programming language that would address the above issues.&amp;lt;ref name=&amp;quot;BG2&amp;quot;&amp;gt;[http://techcrunch.com/2009/11/10/google-go-language TechCrunch]&amp;lt;/ref&amp;gt; They started sketching the goals for a new language on the white board on September 21, 2007. Within a few days the goals had settled into a plan to do something and a fair idea of what it would be. Design continued part-time in parallel with unrelated work.&lt;br /&gt;
By January 2008, Ken had started work on a compiler with which to explore ideas; it generated C code as its output. By mid-year the language had become a full-time project and had settled enough to attempt a production compiler. In May 2008, [http://research.google.com/pubs/author37504.html Ian Taylor] independently started on a [http://en.wikipedia.org/wiki/GNU_Compiler_Collection GCC] front end for Go using the draft specification.  [http://russ.cox.usesthis.com/ Russ Cox] joined in late 2008 and helped move the language and libraries from prototype to reality.&lt;br /&gt;
Go became a public [http://en.wikipedia.org/wiki/Open_source open source project] on November 10, 2009. Many people from the community have contributed ideas, discussions, and code.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Compilers and Runtime support=&lt;br /&gt;
&lt;br /&gt;
There are two Go compiler implementations, [https://golang.org/cmd/gc Gc] (the 6g program and friends) and [http://blog.golang.org/gccgo-in-gcc-471 gccgo ]. Gc uses a different calling convention and linker. It can therefore only be linked with C programs using the same convention. Gccgo is a GCC front-end that can be linked with GCC-compiled C or C++ programs.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cgo program provides the mechanism for a “foreign function interface” to allow safe calling of C libraries from Go code. [http://en.wikipedia.org/wiki/SWIG SWIG] extends this capability to C++ libraries. &lt;br /&gt;
&lt;br /&gt;
Again due to bootstrapping issues, the run-time code is mostly in C (with a tiny bit of assembler) although Go is capable of implementing most of it now. Gccgo's run-time support uses glibc. Gc uses a custom library to keep the footprint under control; it is compiled with a version of the [http://plan9.bell-labs.com/sys/doc/compiler.html Plan 9 C compiler] that supports resizable stacks for goroutines. The gccgo compiler implements these on Linux only, using a technique called segmented stacks, supported by recent modifications to the gold linker.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find all resources needed to compile and run Go Language here http://go-lang.cat-v.org/&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
 &lt;br /&gt;
Programming today involves too much bookkeeping, repetition, and clerical work. As Dick Gabriel says, “Old programs read like quiet conversations between a well-spoken research worker and a well-studied mechanical colleague, not as a debate with a compiler. Who'd have guessed sophistication bought such noise?” The sophistication is worthwhile—no one wants to go back to the old languages—but can it be more quietly achieved?&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Go attempts to reduce the amount of typing in both senses of the word. Throughout its design, &lt;br /&gt;
*They have tried to reduce clutter and complexity. &lt;br /&gt;
*There are no forward declarations and no header files. everything is declared exactly once. &lt;br /&gt;
*Initialization is expressive, automatic, and easy to use. &lt;br /&gt;
*Syntax is clean and light on keywords. Stuttering (foo.Foo* myFoo = new(foo.Foo)) is reduced by simple type derivation using the := declare-and-initialize construct. &lt;br /&gt;
*And perhaps most radically, there is no type hierarchy. They don't have to announce their relationships.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
These simplifications allow Go to be expressive yet comprehensible without sacrificing, well, sophistication.&lt;br /&gt;
Another important principle is to keep the concepts orthogonal. Methods can be implemented for any type; structures represent data while interfaces represent abstraction; and so on. Orthogonality makes it easier to understand what happens when things combine.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Comparison between Go Programming and C++ Programming language &amp;lt;ref name=&amp;quot;KTH&amp;quot;&amp;gt;[http://www.csc.kth.se/utbildning/kth/kurser/DD143X/dkand11/Group9Alexander/Joakim_Anneback_Johan_Stjernberg.finalreport.2.pdf KTH comparison]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;quora&amp;quot;&amp;gt;[http://www.quora.com/How-does-Go-compare-to-C++-and-Java Quora comparison]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;Scriptol&amp;quot;&amp;gt;[http://www.scriptol.com/programming/go.php scriptol]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
Go programming language was developed to run as fast as C++ programs while adding a lot of other modern day features. Some of the key differeneces are listed below&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;2&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Points of Comparison&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Go Programming Language&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | C++ Programming Language&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Primary Focus'''&lt;br /&gt;
|| Go focuses on garbage collection, concurrency and compiling quickly&lt;br /&gt;
|| C++ focuses on inheritance, generic types and pointer arithmetics.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Variable Sizes'''&lt;br /&gt;
|| Machine-independent types are now included without an import needed:  int8, int16, int32, int64, uint8, etc.&lt;br /&gt;
|| Machine-dependent variable sizes&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Class Hierarchies'''&lt;br /&gt;
|| Inheritance is not supported , but with the traditional structures with plain old functions and namespaces, is a MUCH &lt;br /&gt;
better, more flexible approach that leads to better, more maintainable code. &lt;br /&gt;
|| Inheritance is supported but it has its own share of problems like diamond inheritance, virtual inheritance and normal inheritance.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Function overloading'''&lt;br /&gt;
|| Not present in Go because it simplifies dispatch.	&lt;br /&gt;
|| Present in C++.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Genrics'''&lt;br /&gt;
|| Go does not currently support generic types. However, it does support objects without a type using the empty interface.&lt;br /&gt;
|| C++ on the other hand has support for generic types. Generic programming is supported by the use of function templates, class templates and, in some cases, specialized templates in C++.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Multithreading'''&lt;br /&gt;
|| Goroutines are Go's model of threads/coroutines. Each new goroutine runs in parallel with the current computation, in &amp;quot;the same address space. Goroutines are cheap and developers need not to &lt;br /&gt;
worry about the stack size.&lt;br /&gt;
|| In contrast, there is currently no built-in way to manage threads in C++, although the feature is expected in the upcoming new standard and is already today possible using third-party libraries. &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Garbage Collection'''&lt;br /&gt;
|| Go uses garbage collection for memory management, which means that if frees the programmer completely from keeping a track on the memory used.&lt;br /&gt;
|| C++ does not have any garbage collection and hence relies heavily on that the programmer knows what he or she is doing.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Language Design&amp;lt;ref name = &amp;quot;GoLang Book&amp;quot;&amp;gt;[http://www.golang-book.com, GoLang Book]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 package main //line 1&lt;br /&gt;
&lt;br /&gt;
   import “fmt”  //line 2&lt;br /&gt;
&lt;br /&gt;
   func main() {  //line 3&lt;br /&gt;
&lt;br /&gt;
       fmt.Println(“Hello World”) //line 4&lt;br /&gt;
&lt;br /&gt;
   } //line 5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The program above depicts the basic syntax of a program written using Go. Line1 specifies package declaration. Package is used to organize and reuse code. Line 2 is used for including the package “fmt” which is used for formatting input and output. Line 3 to 5 defines the function main. main is the function which is called when a program is executed. Println function in fmt is used to display content to the console i.e in this example Hello World is displayed in the console on executing the program.&lt;br /&gt;
&lt;br /&gt;
==Code Conventions and Style==&lt;br /&gt;
&lt;br /&gt;
* Go fmt tool is used to automatically standardize indentation, spaces and surface-level code details (go vet and go link perform checking automatically).&lt;br /&gt;
* Using tools and libraries provided in Go, there are standard approaches for API documentation (go doc), testing (go test), building( go build) and package management(go get).&lt;br /&gt;
* Syntax prevents any kind of cyclic dependencies.&lt;br /&gt;
* Unused variables and imports are not allowed.&lt;br /&gt;
* Elimination of functional programming constructs (such as map and try/finally) ensure a concrete and explicit programming style.&lt;br /&gt;
&lt;br /&gt;
==Types==&lt;br /&gt;
&lt;br /&gt;
* Numbers are represented in Go as either Integers or Floating point numbers.&lt;br /&gt;
**Integers: Used to represent numbers without a decimal component. Different integers supported by Go are: uint8, uint16, uint32, uint64, int8, int16, int32, int64. Uint is used for unsigned integers and int for signed. 8,16, 32, 64 indicate the number of bits each type would use.&lt;br /&gt;
**Floating Point Integers: Used to support decimal components. Go supports float32 and float64 to represent floating point numbers and complex32 and complex64 to represent complex numbers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var x int32 =4&lt;br /&gt;
var y float32 = 4.5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* String: String literals can be created using either double quotes(“Hello”) or back ticks(`Hello`). Strings have several operations associated them, for example one can find the length of the string or get a character at a specific index in a string. Example below illustrates these functions.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
	fmt.Println(len(“Hello”)) // output: 5&lt;br /&gt;
	fmt.Println(“Hello”[1]) // output: 1&lt;br /&gt;
	fmt.Println(“Hello “+”Tom”) //output: Hello Tom&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Boolean: A 1 bit value is used to represent true or false.&lt;br /&gt;
&lt;br /&gt;
==Variables and Constants==&lt;br /&gt;
*Variabes in Go are indicated using the var keyword. Example: var x string=”hello” . They can also be shorthanded as x:=”hello” .&lt;br /&gt;
*The variable names should begin with a letter and can contain letters, digits or underscore character.&lt;br /&gt;
*The scope of the variable is the block in which it is defined and an attempt to access it outside the block would result in an error on running the program.&lt;br /&gt;
*Go provides support for constants (i.e. variables whose value can not be changed), using the const keyword. Example: const temp string = “Hello”&lt;br /&gt;
*In Go one can define multiple variables(or constants) using the following syntax:&lt;br /&gt;
    var(&lt;br /&gt;
         t1 =1&lt;br /&gt;
         t2=2&lt;br /&gt;
         t3=3&lt;br /&gt;
        t4=4&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Control Structures==&lt;br /&gt;
*For: It is used for repeating a list of statement(s) multiple times. The example below is used for calculating sum of numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    i := 1&lt;br /&gt;
    sum := 0&lt;br /&gt;
&lt;br /&gt;
    for i &amp;lt;= 10 {&lt;br /&gt;
        sum = sum + i&lt;br /&gt;
        i = i + 1&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    fmt.Println(“Sum:” + sum)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the example above i is a loop counter variable and is used to ensure that sum of numbers from 1 to 10 is computed. It indicates the number of times the statements inside the for loop is to be executed. The statement following the keyword for should evaluate to either true or false. If it is evaluated to true the body of for is executed, else we come out of the for loop.&lt;br /&gt;
&lt;br /&gt;
*If: Used to execute a block of statement(s) based on the evaluation of an expression to either true or false. It can also have an else associated with it.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    if i % 2 == 0 {&lt;br /&gt;
        fmt.Println(i + ” is divisble by 2”)&lt;br /&gt;
    } else {&lt;br /&gt;
        fmt.Println(i + “is not divisible by 2”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Switch: The value of the expression following switch is evaluated and is compared against the different cases. Based on the matching case, the block following that case is executed. Switch also has a default case in situations when none of the cases are matching.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    // if op ==1 then so a+b&lt;br /&gt;
    // if op == 2 then do a-b&lt;br /&gt;
    // if op == 3 then do a*b&lt;br /&gt;
    // if op ==4 then do a/b&lt;br /&gt;
    // default print, invalid operator&lt;br /&gt;
&lt;br /&gt;
    op:= 1&lt;br /&gt;
    a=6&lt;br /&gt;
    b=7&lt;br /&gt;
    switch(op) {&lt;br /&gt;
        case 1: fmt.Println(a+b)&lt;br /&gt;
        case 2: fmt.Println(a-b)&lt;br /&gt;
        case 3: fmt.Println(a*b)&lt;br /&gt;
        case 4: fmt.Println(a/b)&lt;br /&gt;
        default: fmt.Println(“Invalid Operator”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Arrays, Slices and Maps==&lt;br /&gt;
&lt;br /&gt;
*Arrays: Numbered sequence of elements starting with index zero and each of the elements having a fixed length. The example below illustrates various operations performed on arrays in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
    var x[10] int&lt;br /&gt;
    x[99]=100&lt;br /&gt;
    fmt.Println(x)  //[0 0 ….. 0 100]&lt;br /&gt;
    fmt.Println(len(x)) //100&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Slices: &lt;br /&gt;
** It is a segment of an array.&lt;br /&gt;
** They have a length and are indexable.&lt;br /&gt;
**In case of a slice the size does not have to specified in the square bracket.&lt;br /&gt;
**Slices support two in-build functions: copy and append.&lt;br /&gt;
**The program below illustrates the different ways to create slices and use of copy and append.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    arr := [10] int {1,2,3,4,5,6,7,8,9,10}&lt;br /&gt;
    x := make([]int,10) // creates a slice [1...10]&lt;br /&gt;
    y := make([]int,10,10) //creates a slice [1...10]&lt;br /&gt;
    z := arr[0:10] //creates a slice [1...10]&lt;br /&gt;
    s1 := []int{1,2,3,4,5}&lt;br /&gt;
    s2 := append(s1, 6, 7)&lt;br /&gt;
    fmt.Println(s1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(s2) // [1,2,3,4,5,6,7]&lt;br /&gt;
    p1 := [] int{1,2,3,4,5}&lt;br /&gt;
    p2 :=make([]int, 4)&lt;br /&gt;
    copy(p2,p1)&lt;br /&gt;
    fmt.Println(p1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(p2)// [1,2,3,4]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Maps:&lt;br /&gt;
**A map is an unordered collection of key value pairs.&lt;br /&gt;
**Syntax: var x map[int] string , where int is the type of the key and string is the type of the value.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
    x := make(map[int]string)&lt;br /&gt;
    x[1] = one&lt;br /&gt;
    x[2] = two&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
&lt;br /&gt;
*In Go functions can take multiple inputs and return multiple outputs.&lt;br /&gt;
*Go supports a special kind of function called variadic function.&lt;br /&gt;
*Closure is the means by which functions can be created inside other function in Go.&lt;br /&gt;
*Go supports recursive functions.&lt;br /&gt;
*The example below the different types of function in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    display(“Hello World”)&lt;br /&gt;
    sum :=calculateSum(10,20)&lt;br /&gt;
    v1,v2=multipleValues()&lt;br /&gt;
    p=product(5,10,20)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function without return type&lt;br /&gt;
func display( s string) {&lt;br /&gt;
    fmt.Println(s)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns a single value&lt;br /&gt;
func calculateSum(a int, b int) int {&lt;br /&gt;
    c: = a + b&lt;br /&gt;
    return c&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns multiple values&lt;br /&gt;
func multipleValues(int, int) {&lt;br /&gt;
    return 1, 2&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Variadic function&lt;br /&gt;
func product(args ...int) int {&lt;br /&gt;
    p := 1&lt;br /&gt;
   for _, i := range args {&lt;br /&gt;
        p *= i&lt;br /&gt;
   }&lt;br /&gt;
   return p&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pointers==&lt;br /&gt;
It is used to reference a location in the memory where the value is stored rather than containing the value itself. Basic pointer operations in Go are illustrated in the example below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
//Different syntax for pointers&lt;br /&gt;
    &lt;br /&gt;
     ptr1 *int&lt;br /&gt;
     num :=10&lt;br /&gt;
     ptr1 = &amp;amp;num&lt;br /&gt;
     ptr2 := new(int)&lt;br /&gt;
     ptr2=&amp;amp;num&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Concurrency==&lt;br /&gt;
* Go ensures concurrency which allows sharing of state using communication mechanisms.&lt;br /&gt;
* Go provides support for multithreading and CPU parallelization.&lt;br /&gt;
* Go supports asynchrony i.e. allows operations like database and network I/O which are slow operations to occur in parallel along with other operations.&lt;br /&gt;
* A new lightweight process is created using go fund()&lt;br /&gt;
* Channel types are used for providing type safe and synchronized channels between different go routines.&lt;br /&gt;
&lt;br /&gt;
=Users of Go=&lt;br /&gt;
Apart from Google, which uses Go programming for some of its development, companies like [http://en.wikipedia.org/wiki/Dropbox_(service) Dropbox], [http://en.wikipedia.org/wiki/CloudFlare CloudFlare], [http://en.wikipedia.org/wiki/SoundCloud SoundCloud], The BBC, Novartis, Cloud Foundry also use Go programming.  &lt;br /&gt;
Dropbox server (running in the cloud) and desktop client software were primarily written in [http://en.wikipedia.org/wiki/Python_(programming_language) Python]. From mid-2013 Dropbox began migrating its backend infrastructure to Go.&lt;br /&gt;
Some of the open-source applications that are using Go programming are Docker, Flynn, PaaS, Juju, nsq, Doozer e.t.c .&amp;lt;ref name = &amp;quot;GoWIKI&amp;quot;&amp;gt;[http://en.wikipedia.org/wiki/Go_(programming_language), Wikipedia]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advantages&amp;lt;ref name=&amp;quot;csdn&amp;quot;&amp;gt; [http://blog.csdn.net/lymemoryzz/article/details/20960997 CSDN blog]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
 &lt;br /&gt;
*'''C Level Performance'''. golang is within a close margin of the performance level of C code (which is itself an extremely high performance language). It is certainly closer to the performance of native languages than other enterprise level languages such as Java, Scala, Erlang etc.&lt;br /&gt;
 &lt;br /&gt;
*'''Fast Compilation''' is one of the key advantages of Go language. The Golang compiler was designed to compile programs very quickly. Extremely large programs with massively high LOC counts compile seemingly instantly - after all, Golang was designed by Google to solve Google problems, and Google has big problems! At Google, code and CPU cores are both measured in the millions. Go provides a model for software construction that makes dependency analysis easy and avoids much of the overhead of C-style include files and libraries.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reduced compile time is a key improvement in the Go language&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      If A.go depends on B.go depends on C.go :&lt;br /&gt;
         Compile C.go, B.go then A.go normally (other languages)&lt;br /&gt;
         To compile A.go, compiler reads B.o not C.o (go)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At a large scale this should help in hugely speeding up&lt;br /&gt;
&lt;br /&gt;
Other advantages are      &lt;br /&gt;
* '''Concurrency Supported At Language Level'''. Concurrency is the ability to execute multiple computations simultaneously. In today's modern multicore and high-load computing environment, concurrency is a critical language feature, and one in which languages such as Java struggle immensely.&lt;br /&gt;
* By its design, Go proposes an approach for the construction of system software on '''multicore machines'''.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
* Google have summed things up nicely with their motto: '''Don't communicate by sharing memory, share memory by communicating'''.Channels allow you to pass references to data structures between goroutines. If you consider this as passing around ownership of the data (the ability to read and write it), they become a powerful and expressive synchronization mechanism.  &lt;br /&gt;
* '''Go's type system has no hierarchy''', so no time is spent defining the relationships between types. Also, although Go has static types, the language attempts to make types feel lighter weight than in typical Object Oriented languages.&lt;br /&gt;
* '''Garbage Collection is much better'''. In C and C++, programmers spend a lot of time and energy on allocating and freeing memory. The designers of Go wanted to remove that complication, and ensure Go programmers could concentrate on more productive tasks. As such, they implemented garbage collection. As a developer, this is a very good thing. Sure, garbage collection comes with its own set of issues, but those are dealt with by the language implementer while the programmer is free to reap the other many benefits of Go.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
*Go is still an experimental language subject to change.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;&amp;gt;[http://stackoverflow.com/questions/2198529/what-are-the-advantages-and-disadvantages-of-go-programming-language stackoverflow]&amp;lt;/ref&amp;gt;&lt;br /&gt;
*Go's not very usable on Windows yet.&lt;br /&gt;
*The packages distributed with Go are pretty useful, but there are still some libraries you'll miss. Most notably a UI toolkit.&lt;br /&gt;
*There is no support for generics in Go, although there are many discussions around it.&lt;br /&gt;
*Confusing Semantics Of Exported Identifiers&amp;lt;ref name = &amp;quot;Limitations2&amp;quot;&amp;gt;&lt;br /&gt;
[https://functionwhatwhat.com/go’s-type-system-is-an-embarrassment functionwhatwhat ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=88576</id>
		<title>CSC/ECE 517 Fall 2014/ch1a 10 hu</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=88576"/>
		<updated>2014-09-26T00:51:51Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Code Conventions and Style */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==''' Go Programming Language''' ==&lt;br /&gt;
'''Go''', also commonly referred to as '''golang''', is a compiled, concurrent, garbage-collected, statically typed language developed at [http://en.wikipedia.org/wiki/Google Google]. It was developed by [http://en.wikipedia.org/wiki/Robert_Griesemer Robert Griesemer], [http://en.wikipedia.org/wiki/Rob_Pike Rob Pike] and [http://en.wikipedia.org/wiki/Ken_Thompson Ken Thompson] in 2007. It was announced in November 2009 and is currently being used in many production systems at Google. It is an open source project. The syntax is loosely derived from that of [http://en.wikipedia.org/wiki/C_(programming_language) C programming language], adding [http://en.wikipedia.org/wiki/Garbage_collection_(computer_science) garbage collection], type safety, some dynamic-typing capabilities. Additional built-in types such as variable-length arrays and key-value maps, and a large standard library are also supported. Different operating systems like Linux, Microsoft Windows, Mac OS X are suported by [https://golang.org/cmd/gc Gc] compiler of Go.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
&lt;br /&gt;
Go programming started of as a research project by Robert Griesemer, Rob Pike and Ken Thompson. They felt that there was no new system focused programming language that has come up in the last decade till 2008, while there were other developments like increase in the size of libraries, dominance of networking , client server focus, multi-core CPUs.&amp;lt;ref name = &amp;quot;Background 1&amp;quot;&amp;gt;[https://www.youtube.com/watch?v=rKnDgT73v8s Go Language Introduction speech]&amp;lt;/ref&amp;gt; So they wanted to come up with a new systems focused programming language that would address the above issues.&amp;lt;ref name=&amp;quot;BG2&amp;quot;&amp;gt;[http://techcrunch.com/2009/11/10/google-go-language TechCrunch]&amp;lt;/ref&amp;gt; They started sketching the goals for a new language on the white board on September 21, 2007. Within a few days the goals had settled into a plan to do something and a fair idea of what it would be. Design continued part-time in parallel with unrelated work.&lt;br /&gt;
By January 2008, Ken had started work on a compiler with which to explore ideas; it generated C code as its output. By mid-year the language had become a full-time project and had settled enough to attempt a production compiler. In May 2008, [http://research.google.com/pubs/author37504.html Ian Taylor] independently started on a [http://en.wikipedia.org/wiki/GNU_Compiler_Collection GCC] front end for Go using the draft specification.  [http://russ.cox.usesthis.com/ Russ Cox] joined in late 2008 and helped move the language and libraries from prototype to reality.&lt;br /&gt;
Go became a public [http://en.wikipedia.org/wiki/Open_source open source project] on November 10, 2009. Many people from the community have contributed ideas, discussions, and code.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Compilers and Runtime support=&lt;br /&gt;
&lt;br /&gt;
There are two Go compiler implementations, [https://golang.org/cmd/gc Gc] (the 6g program and friends) and [http://blog.golang.org/gccgo-in-gcc-471 gccgo ]. Gc uses a different calling convention and linker. It can therefore only be linked with C programs using the same convention. Gccgo is a GCC front-end that can be linked with GCC-compiled C or C++ programs.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cgo program provides the mechanism for a “foreign function interface” to allow safe calling of C libraries from Go code. [http://en.wikipedia.org/wiki/SWIG SWIG] extends this capability to C++ libraries. &lt;br /&gt;
&lt;br /&gt;
Again due to bootstrapping issues, the run-time code is mostly in C (with a tiny bit of assembler) although Go is capable of implementing most of it now. Gccgo's run-time support uses glibc. Gc uses a custom library to keep the footprint under control; it is compiled with a version of the [http://plan9.bell-labs.com/sys/doc/compiler.html Plan 9 C compiler] that supports resizable stacks for goroutines. The gccgo compiler implements these on Linux only, using a technique called segmented stacks, supported by recent modifications to the gold linker.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find all resources needed to compile and run Go Language here http://go-lang.cat-v.org/&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
 &lt;br /&gt;
Programming today involves too much bookkeeping, repetition, and clerical work. As Dick Gabriel says, “Old programs read like quiet conversations between a well-spoken research worker and a well-studied mechanical colleague, not as a debate with a compiler. Who'd have guessed sophistication bought such noise?” The sophistication is worthwhile—no one wants to go back to the old languages—but can it be more quietly achieved?&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Go attempts to reduce the amount of typing in both senses of the word. Throughout its design, &lt;br /&gt;
*They have tried to reduce clutter and complexity. &lt;br /&gt;
*There are no forward declarations and no header files. everything is declared exactly once. &lt;br /&gt;
*Initialization is expressive, automatic, and easy to use. &lt;br /&gt;
*Syntax is clean and light on keywords. Stuttering (foo.Foo* myFoo = new(foo.Foo)) is reduced by simple type derivation using the := declare-and-initialize construct. &lt;br /&gt;
*And perhaps most radically, there is no type hierarchy. They don't have to announce their relationships.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
These simplifications allow Go to be expressive yet comprehensible without sacrificing, well, sophistication.&lt;br /&gt;
Another important principle is to keep the concepts orthogonal. Methods can be implemented for any type; structures represent data while interfaces represent abstraction; and so on. Orthogonality makes it easier to understand what happens when things combine.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Comparison between Go Programming and C++ Programming language &amp;lt;ref name=&amp;quot;KTH&amp;quot;&amp;gt;[http://www.csc.kth.se/utbildning/kth/kurser/DD143X/dkand11/Group9Alexander/Joakim_Anneback_Johan_Stjernberg.finalreport.2.pdf KTH comparison]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;quora&amp;quot;&amp;gt;[http://www.quora.com/How-does-Go-compare-to-C++-and-Java Quora comparison]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;Scriptol&amp;quot;&amp;gt;[http://www.scriptol.com/programming/go.php scriptol]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
Go programming language was developed to run as fast as C++ programs while adding a lot of other modern day features. Some of the key differeneces are listed below&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;2&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Points of Comparison&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Go Programming Language&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | C++ Programming Language&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Primary Focus'''&lt;br /&gt;
|| Go focuses on garbage collection, concurrency and compiling quickly&lt;br /&gt;
|| C++ focuses on inheritance, generic types and pointer arithmetics.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Variable Sizes'''&lt;br /&gt;
|| Machine-independent types are now included without an import needed:  int8, int16, int32, int64, uint8, etc.&lt;br /&gt;
|| Machine-dependent variable sizes&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Class Hierarchies'''&lt;br /&gt;
|| Inheritance is not supported , but with the traditional structures with plain old functions and namespaces, is a MUCH &lt;br /&gt;
better, more flexible approach that leads to better, more maintainable code. &lt;br /&gt;
|| Inheritance is supported but it has its own share of problems like diamond inheritance, virtual inheritance and normal inheritance.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Function overloading'''&lt;br /&gt;
|| Not present in Go because it simplifies dispatch.	&lt;br /&gt;
|| Present in C++.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Genrics'''&lt;br /&gt;
|| Go does not currently support generic types. However, it does support objects without a type using the empty interface.&lt;br /&gt;
|| C++ on the other hand has support for generic types. Generic programming is supported by the use of function templates, class templates and, in some cases, specialized templates in C++.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Multithreading'''&lt;br /&gt;
|| Goroutines are Go's model of threads/coroutines. Each new goroutine runs in parallel with the current computation, in &amp;quot;the same address space. Goroutines are cheap and developers need not to &lt;br /&gt;
worry about the stack size.&lt;br /&gt;
|| In contrast, there is currently no built-in way to manage threads in C++, although the feature is expected in the upcoming new standard and is already today possible using third-party libraries. &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Garbage Collection'''&lt;br /&gt;
|| Go uses garbage collection for memory management, which means that if frees the programmer completely from keeping a track on the memory used.&lt;br /&gt;
|| C++ does not have any garbage collection and hence relies heavily on that the programmer knows what he or she is doing.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Language Design&amp;lt;ref name = &amp;quot;GoLang Book&amp;quot;&amp;gt;[http://www.golang-book.com, GoLang Book]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 package main //line 1&lt;br /&gt;
&lt;br /&gt;
   import “fmt”  //line 2&lt;br /&gt;
&lt;br /&gt;
   func main() {  //line 3&lt;br /&gt;
&lt;br /&gt;
       fmt.Println(“Hello World”) //line 4&lt;br /&gt;
&lt;br /&gt;
   } //line 5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The program above depicts the basic syntax of a program written using Go. Line1 specifies package declaration. Package is used to organize and reuse code. Line 2 is used for including the package “fmt” which is used for formatting input and output. Line 3 to 5 defines the function main. main is the function which is called when a program is executed. Println function in fmt is used to display content to the console i.e in this example Hello World is displayed in the console on executing the program.&lt;br /&gt;
&lt;br /&gt;
==Code Conventions and Style==&lt;br /&gt;
&lt;br /&gt;
* Go fmt tool is used to automatically standardize indentation, spaces and surface-level code details (go vet and go link perform checking automatically).&lt;br /&gt;
* Using tools and libraries provided in Go, there are standard approaches for API documentation (go doc), testing (go test), building( go build) and package management(go get).&lt;br /&gt;
* Syntax prevents any kind of cyclic dependencies.&lt;br /&gt;
* Unused variables and imports are not allowed.&lt;br /&gt;
* Elimination of functional programming constructs (such as map and try/finally) ensure a concrete and explicit programming style.&lt;br /&gt;
&lt;br /&gt;
==Types==&lt;br /&gt;
&lt;br /&gt;
* Numbers are represented in Go as either Integers or Floating point numbers.&lt;br /&gt;
**Integers: Used to represent numbers without a decimal component. Different integers supported by Go are: uint8, uint16, uint32, uint64, int8, int16, int32, int64. Uint is used for unsigned integers and int for signed. 8,16, 32, 64 indicate the number of bits each type would use.&lt;br /&gt;
**Floating Point Integers: Used to support decimal components. Go supports float32 and float64 to represent floating point numbers and complex32 and complex64 to represent complex numbers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var x int32 =4&lt;br /&gt;
var y float32 = 4.5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* String: String litersals can be created using either double quotes(“Hello”) or back ticks(`Hello`). Strings have several operations associated them, for example one can find the length of the string or get a character at a specific index in a string.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
	fmt.Println(len(“Hello”)) // output: 5&lt;br /&gt;
	fmt.Println(“Hello”[1]) // output: 1&lt;br /&gt;
	fmt.Println(“Hello “+”Tom”) //output: Hello Tom&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Boolean: A 1 bit value is used to represent true or false.&lt;br /&gt;
&lt;br /&gt;
==Variables and Constants==&lt;br /&gt;
*Variabes in Go are indicated using the var keyword. Example: var x string=”hello” . They can also be shorthanded as x:=”hello” .&lt;br /&gt;
*The variable names should begin with a letter and can contain letters, digits or underscore character.&lt;br /&gt;
*The scope of the variable is the block in which it is defined and an attempt to access it outside the block would result in an error on running the program.&lt;br /&gt;
*Go provides support for constants (i.e. variables whose value can not be changed), using the const keyword. Example: const temp string = “Hello”&lt;br /&gt;
*In Go one can define multiple variables(or constants) using the following syntax:&lt;br /&gt;
    var(&lt;br /&gt;
         t1 =1&lt;br /&gt;
         t2=2&lt;br /&gt;
         t3=3&lt;br /&gt;
        t4=4&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Control Structures==&lt;br /&gt;
*For: It is used for repeating a list of statement(s) multiple times. The example below is used for calculating sum of numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    i := 1&lt;br /&gt;
    sum := 0&lt;br /&gt;
&lt;br /&gt;
    for i &amp;lt;= 10 {&lt;br /&gt;
        sum = sum + i&lt;br /&gt;
        i = i + 1&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    fmt.Println(“Sum:” + sum)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the example above i is a loop counter variable and is used to ensure that sum of numbers from 1 to 10 is computed. It indicates the number of times the statements inside the for loop is to be executed. The statement following the keyword for should evaluate to either true or false. If it is evaluated to true the body of for is executed, else we come out of the for loop.&lt;br /&gt;
&lt;br /&gt;
*If: Used to execute a block of statement(s) based on the evaluation of an expression to either true or false. It can also have an else associated with it.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    if i % 2 == 0 {&lt;br /&gt;
        fmt.Println(i + ” is divisble by 2”)&lt;br /&gt;
    } else {&lt;br /&gt;
        fmt.Println(i + “is not divisible by 2”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Switch: The value of the expression following switch is evaluated and is compared against the different cases. Based on the matching case, the block following that case is executed. Switch also has a default case in situations when none of the cases are matching.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    // if op ==1 then so a+b&lt;br /&gt;
    // if op == 2 then do a-b&lt;br /&gt;
    // if op == 3 then do a*b&lt;br /&gt;
    // if op ==4 then do a/b&lt;br /&gt;
    // default print, invalid operator&lt;br /&gt;
&lt;br /&gt;
    op:= 1&lt;br /&gt;
    a=6&lt;br /&gt;
    b=7&lt;br /&gt;
    switch(op) {&lt;br /&gt;
        case 1: fmt.Println(a+b)&lt;br /&gt;
        case 2: fmt.Println(a-b)&lt;br /&gt;
        case 3: fmt.Println(a*b)&lt;br /&gt;
        case 4: fmt.Println(a/b)&lt;br /&gt;
        default: fmt.Println(“Invalid Operator”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Arrays, Slices and Maps==&lt;br /&gt;
&lt;br /&gt;
*Arrays: Numbered sequence of elements starting with index zero and each of the elements having a fixed length. The example below illustrates various operations performed on arrays in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
    var x[10] int&lt;br /&gt;
    x[99]=100&lt;br /&gt;
    fmt.Println(x)  //[0 0 ….. 0 100]&lt;br /&gt;
    fmt.Println(len(x)) //100&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Slices: &lt;br /&gt;
** It is a segment of an array.&lt;br /&gt;
** They have a length and are indexable.&lt;br /&gt;
**In case of a slice the size does not have to specified in the square bracket.&lt;br /&gt;
**Slices support two in-build functions: copy and append.&lt;br /&gt;
**The program below illustrates the different ways to create slices and use of copy and append.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    arr := [10] int {1,2,3,4,5,6,7,8,9,10}&lt;br /&gt;
    x := make([]int,10) // creates a slice [1...10]&lt;br /&gt;
    y := make([]int,10,10) //creates a slice [1...10]&lt;br /&gt;
    z := arr[0:10] //creates a slice [1...10]&lt;br /&gt;
    s1 := []int{1,2,3,4,5}&lt;br /&gt;
    s2 := append(s1, 6, 7)&lt;br /&gt;
    fmt.Println(s1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(s2) // [1,2,3,4,5,6,7]&lt;br /&gt;
    p1 := [] int{1,2,3,4,5}&lt;br /&gt;
    p2 :=make([]int, 4)&lt;br /&gt;
    copy(p2,p1)&lt;br /&gt;
    fmt.Println(p1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(p2)// [1,2,3,4]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Maps:&lt;br /&gt;
**A map is an unordered collection of key value pairs.&lt;br /&gt;
**Syntax: var x map[int] string , where int is the type of the key and string is the type of the value.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
    x := make(map[int]string)&lt;br /&gt;
    x[1] = one&lt;br /&gt;
    x[2] = two&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
&lt;br /&gt;
*In Go functions can take multiple inputs and return multiple outputs.&lt;br /&gt;
*Go supports a special kind of function called variadic function.&lt;br /&gt;
*Closure is the means by which functions can be created inside other function in Go.&lt;br /&gt;
*Go supports recursive functions.&lt;br /&gt;
*The example below the different types of function in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    display(“Hello World”)&lt;br /&gt;
    sum :=calculateSum(10,20)&lt;br /&gt;
    v1,v2=multipleValues()&lt;br /&gt;
    p=product(5,10,20)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function without return type&lt;br /&gt;
func display( s string) {&lt;br /&gt;
    fmt.Println(s)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns a single value&lt;br /&gt;
func calculateSum(a int, b int) int {&lt;br /&gt;
    c: = a + b&lt;br /&gt;
    return c&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns multiple values&lt;br /&gt;
func multipleValues(int, int) {&lt;br /&gt;
    return 1, 2&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Variadic function&lt;br /&gt;
func product(args ...int) int {&lt;br /&gt;
    p := 1&lt;br /&gt;
   for _, i := range args {&lt;br /&gt;
        p *= i&lt;br /&gt;
   }&lt;br /&gt;
   return p&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pointers==&lt;br /&gt;
It is used to reference a location in the memory where the value is stored rather than containing the value itself. Basic pointer operations in Go are illustrated in the example below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
//Different syntax for pointers&lt;br /&gt;
    &lt;br /&gt;
     ptr1 *int&lt;br /&gt;
     num :=10&lt;br /&gt;
     ptr1 = &amp;amp;num&lt;br /&gt;
     ptr2 := new(int)&lt;br /&gt;
     ptr2=&amp;amp;num&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Concurrency==&lt;br /&gt;
* Go ensures concurrency which allows sharing of state using communication mechanisms.&lt;br /&gt;
* Go provides support for multithreading and CPU parallelization.&lt;br /&gt;
* Go supports asynchrony i.e. allows operations like database and network I/O which are slow operations to occur in parallel along with other operations.&lt;br /&gt;
* A new lightweight process is created using go fund()&lt;br /&gt;
* Channel types are used for providing type safe and synchronized channels between different go routines.&lt;br /&gt;
&lt;br /&gt;
=Users of Go=&lt;br /&gt;
Apart from Google, which uses Go programming for some of its development, companies like [http://en.wikipedia.org/wiki/Dropbox_(service) Dropbox], [http://en.wikipedia.org/wiki/CloudFlare CloudFlare], [http://en.wikipedia.org/wiki/SoundCloud SoundCloud], The BBC, Novartis, Cloud Foundry also use Go programming.  &lt;br /&gt;
Dropbox server (running in the cloud) and desktop client software were primarily written in [http://en.wikipedia.org/wiki/Python_(programming_language) Python]. From mid-2013 Dropbox began migrating its backend infrastructure to Go.&lt;br /&gt;
Some of the open-source applications that are using Go programming are Docker, Flynn, PaaS, Juju, nsq, Doozer e.t.c .&amp;lt;ref name = &amp;quot;GoWIKI&amp;quot;&amp;gt;[http://en.wikipedia.org/wiki/Go_(programming_language), Wikipedia]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advantages&amp;lt;ref name=&amp;quot;csdn&amp;quot;&amp;gt; [http://blog.csdn.net/lymemoryzz/article/details/20960997 CSDN blog]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
 &lt;br /&gt;
*'''C Level Performance'''. golang is within a close margin of the performance level of C code (which is itself an extremely high performance language). It is certainly closer to the performance of native languages than other enterprise level languages such as Java, Scala, Erlang etc.&lt;br /&gt;
 &lt;br /&gt;
*'''Fast Compilation''' is one of the key advantages of Go language. The Golang compiler was designed to compile programs very quickly. Extremely large programs with massively high LOC counts compile seemingly instantly - after all, Golang was designed by Google to solve Google problems, and Google has big problems! At Google, code and CPU cores are both measured in the millions. Go provides a model for software construction that makes dependency analysis easy and avoids much of the overhead of C-style include files and libraries.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reduced compile time is a key improvement in the Go language&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      If A.go depends on B.go depends on C.go :&lt;br /&gt;
         Compile C.go, B.go then A.go normally (other languages)&lt;br /&gt;
         To compile A.go, compiler reads B.o not C.o (go)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At a large scale this should help in hugely speeding up&lt;br /&gt;
&lt;br /&gt;
Other advantages are      &lt;br /&gt;
* '''Concurrency Supported At Language Level'''. Concurrency is the ability to execute multiple computations simultaneously. In today's modern multicore and high-load computing environment, concurrency is a critical language feature, and one in which languages such as Java struggle immensely.&lt;br /&gt;
* By its design, Go proposes an approach for the construction of system software on '''multicore machines'''.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
* Google have summed things up nicely with their motto: '''Don't communicate by sharing memory, share memory by communicating'''.Channels allow you to pass references to data structures between goroutines. If you consider this as passing around ownership of the data (the ability to read and write it), they become a powerful and expressive synchronization mechanism.  &lt;br /&gt;
* '''Go's type system has no hierarchy''', so no time is spent defining the relationships between types. Also, although Go has static types, the language attempts to make types feel lighter weight than in typical Object Oriented languages.&lt;br /&gt;
* '''Garbage Collection is much better'''. In C and C++, programmers spend a lot of time and energy on allocating and freeing memory. The designers of Go wanted to remove that complication, and ensure Go programmers could concentrate on more productive tasks. As such, they implemented garbage collection. As a developer, this is a very good thing. Sure, garbage collection comes with its own set of issues, but those are dealt with by the language implementer while the programmer is free to reap the other many benefits of Go.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
*Go is still an experimental language subject to change.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;&amp;gt;[http://stackoverflow.com/questions/2198529/what-are-the-advantages-and-disadvantages-of-go-programming-language stackoverflow]&amp;lt;/ref&amp;gt;&lt;br /&gt;
*Go's not very usable on Windows yet.&lt;br /&gt;
*The packages distributed with Go are pretty useful, but there are still some libraries you'll miss. Most notably a UI toolkit.&lt;br /&gt;
*There is no support for generics in Go, although there are many discussions around it.&lt;br /&gt;
*Confusing Semantics Of Exported Identifiers&amp;lt;ref name = &amp;quot;Limitations2&amp;quot;&amp;gt;&lt;br /&gt;
[https://functionwhatwhat.com/go’s-type-system-is-an-embarrassment functionwhatwhat ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=88575</id>
		<title>CSC/ECE 517 Fall 2014/ch1a 10 hu</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=88575"/>
		<updated>2014-09-26T00:50:51Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==''' Go Programming Language''' ==&lt;br /&gt;
'''Go''', also commonly referred to as '''golang''', is a compiled, concurrent, garbage-collected, statically typed language developed at [http://en.wikipedia.org/wiki/Google Google]. It was developed by [http://en.wikipedia.org/wiki/Robert_Griesemer Robert Griesemer], [http://en.wikipedia.org/wiki/Rob_Pike Rob Pike] and [http://en.wikipedia.org/wiki/Ken_Thompson Ken Thompson] in 2007. It was announced in November 2009 and is currently being used in many production systems at Google. It is an open source project. The syntax is loosely derived from that of [http://en.wikipedia.org/wiki/C_(programming_language) C programming language], adding [http://en.wikipedia.org/wiki/Garbage_collection_(computer_science) garbage collection], type safety, some dynamic-typing capabilities. Additional built-in types such as variable-length arrays and key-value maps, and a large standard library are also supported. Different operating systems like Linux, Microsoft Windows, Mac OS X are suported by [https://golang.org/cmd/gc Gc] compiler of Go.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
&lt;br /&gt;
Go programming started of as a research project by Robert Griesemer, Rob Pike and Ken Thompson. They felt that there was no new system focused programming language that has come up in the last decade till 2008, while there were other developments like increase in the size of libraries, dominance of networking , client server focus, multi-core CPUs.&amp;lt;ref name = &amp;quot;Background 1&amp;quot;&amp;gt;[https://www.youtube.com/watch?v=rKnDgT73v8s Go Language Introduction speech]&amp;lt;/ref&amp;gt; So they wanted to come up with a new systems focused programming language that would address the above issues.&amp;lt;ref name=&amp;quot;BG2&amp;quot;&amp;gt;[http://techcrunch.com/2009/11/10/google-go-language TechCrunch]&amp;lt;/ref&amp;gt; They started sketching the goals for a new language on the white board on September 21, 2007. Within a few days the goals had settled into a plan to do something and a fair idea of what it would be. Design continued part-time in parallel with unrelated work.&lt;br /&gt;
By January 2008, Ken had started work on a compiler with which to explore ideas; it generated C code as its output. By mid-year the language had become a full-time project and had settled enough to attempt a production compiler. In May 2008, [http://research.google.com/pubs/author37504.html Ian Taylor] independently started on a [http://en.wikipedia.org/wiki/GNU_Compiler_Collection GCC] front end for Go using the draft specification.  [http://russ.cox.usesthis.com/ Russ Cox] joined in late 2008 and helped move the language and libraries from prototype to reality.&lt;br /&gt;
Go became a public [http://en.wikipedia.org/wiki/Open_source open source project] on November 10, 2009. Many people from the community have contributed ideas, discussions, and code.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Compilers and Runtime support=&lt;br /&gt;
&lt;br /&gt;
There are two Go compiler implementations, [https://golang.org/cmd/gc Gc] (the 6g program and friends) and [http://blog.golang.org/gccgo-in-gcc-471 gccgo ]. Gc uses a different calling convention and linker. It can therefore only be linked with C programs using the same convention. Gccgo is a GCC front-end that can be linked with GCC-compiled C or C++ programs.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cgo program provides the mechanism for a “foreign function interface” to allow safe calling of C libraries from Go code. [http://en.wikipedia.org/wiki/SWIG SWIG] extends this capability to C++ libraries. &lt;br /&gt;
&lt;br /&gt;
Again due to bootstrapping issues, the run-time code is mostly in C (with a tiny bit of assembler) although Go is capable of implementing most of it now. Gccgo's run-time support uses glibc. Gc uses a custom library to keep the footprint under control; it is compiled with a version of the [http://plan9.bell-labs.com/sys/doc/compiler.html Plan 9 C compiler] that supports resizable stacks for goroutines. The gccgo compiler implements these on Linux only, using a technique called segmented stacks, supported by recent modifications to the gold linker.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find all resources needed to compile and run Go Language here http://go-lang.cat-v.org/&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
 &lt;br /&gt;
Programming today involves too much bookkeeping, repetition, and clerical work. As Dick Gabriel says, “Old programs read like quiet conversations between a well-spoken research worker and a well-studied mechanical colleague, not as a debate with a compiler. Who'd have guessed sophistication bought such noise?” The sophistication is worthwhile—no one wants to go back to the old languages—but can it be more quietly achieved?&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Go attempts to reduce the amount of typing in both senses of the word. Throughout its design, &lt;br /&gt;
*They have tried to reduce clutter and complexity. &lt;br /&gt;
*There are no forward declarations and no header files. everything is declared exactly once. &lt;br /&gt;
*Initialization is expressive, automatic, and easy to use. &lt;br /&gt;
*Syntax is clean and light on keywords. Stuttering (foo.Foo* myFoo = new(foo.Foo)) is reduced by simple type derivation using the := declare-and-initialize construct. &lt;br /&gt;
*And perhaps most radically, there is no type hierarchy. They don't have to announce their relationships.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
These simplifications allow Go to be expressive yet comprehensible without sacrificing, well, sophistication.&lt;br /&gt;
Another important principle is to keep the concepts orthogonal. Methods can be implemented for any type; structures represent data while interfaces represent abstraction; and so on. Orthogonality makes it easier to understand what happens when things combine.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Comparison between Go Programming and C++ Programming language &amp;lt;ref name=&amp;quot;KTH&amp;quot;&amp;gt;[http://www.csc.kth.se/utbildning/kth/kurser/DD143X/dkand11/Group9Alexander/Joakim_Anneback_Johan_Stjernberg.finalreport.2.pdf KTH comparison]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;quora&amp;quot;&amp;gt;[http://www.quora.com/How-does-Go-compare-to-C++-and-Java Quora comparison]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;Scriptol&amp;quot;&amp;gt;[http://www.scriptol.com/programming/go.php scriptol]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
Go programming language was developed to run as fast as C++ programs while adding a lot of other modern day features. Some of the key differeneces are listed below&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;2&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Points of Comparison&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Go Programming Language&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | C++ Programming Language&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Primary Focus'''&lt;br /&gt;
|| Go focuses on garbage collection, concurrency and compiling quickly&lt;br /&gt;
|| C++ focuses on inheritance, generic types and pointer arithmetics.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Variable Sizes'''&lt;br /&gt;
|| Machine-independent types are now included without an import needed:  int8, int16, int32, int64, uint8, etc.&lt;br /&gt;
|| Machine-dependent variable sizes&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Class Hierarchies'''&lt;br /&gt;
|| Inheritance is not supported , but with the traditional structures with plain old functions and namespaces, is a MUCH &lt;br /&gt;
better, more flexible approach that leads to better, more maintainable code. &lt;br /&gt;
|| Inheritance is supported but it has its own share of problems like diamond inheritance, virtual inheritance and normal inheritance.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Function overloading'''&lt;br /&gt;
|| Not present in Go because it simplifies dispatch.	&lt;br /&gt;
|| Present in C++.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Genrics'''&lt;br /&gt;
|| Go does not currently support generic types. However, it does support objects without a type using the empty interface.&lt;br /&gt;
|| C++ on the other hand has support for generic types. Generic programming is supported by the use of function templates, class templates and, in some cases, specialized templates in C++.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Multithreading'''&lt;br /&gt;
|| Goroutines are Go's model of threads/coroutines. Each new goroutine runs in parallel with the current computation, in &amp;quot;the same address space. Goroutines are cheap and developers need not to &lt;br /&gt;
worry about the stack size.&lt;br /&gt;
|| In contrast, there is currently no built-in way to manage threads in C++, although the feature is expected in the upcoming new standard and is already today possible using third-party libraries. &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Garbage Collection'''&lt;br /&gt;
|| Go uses garbage collection for memory management, which means that if frees the programmer completely from keeping a track on the memory used.&lt;br /&gt;
|| C++ does not have any garbage collection and hence relies heavily on that the programmer knows what he or she is doing.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Language Design&amp;lt;ref name = &amp;quot;GoLang Book&amp;quot;&amp;gt;[http://www.golang-book.com, GoLang Book]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 package main //line 1&lt;br /&gt;
&lt;br /&gt;
   import “fmt”  //line 2&lt;br /&gt;
&lt;br /&gt;
   func main() {  //line 3&lt;br /&gt;
&lt;br /&gt;
       fmt.Println(“Hello World”) //line 4&lt;br /&gt;
&lt;br /&gt;
   } //line 5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The program above depicts the basic syntax of a program written using Go. Line1 specifies package declaration. Package is used to organize and reuse code. Line 2 is used for including the package “fmt” which is used for formatting input and output. Line 3 to 5 defines the function main. main is the function which is called when a program is executed. Println function in fmt is used to display content to the console i.e in this example Hello World is displayed in the console on executing the program.&lt;br /&gt;
&lt;br /&gt;
==Code Conventions and Style==&lt;br /&gt;
&lt;br /&gt;
* Go fmt tool is used to automatically standardize indentation, spaces and surface-level code details. go vet and go link are perform checking automatically.&lt;br /&gt;
* Using tools and libraries provided in Go, there are standard approaches for API documentation(go doc), testing(go test), building(go build) and package management(go get).&lt;br /&gt;
* Syntax prevents any kind of cyclic dependencies.&lt;br /&gt;
* Unused variables and imports are not allowed.&lt;br /&gt;
* Elimination of functional programming constructs (such as map and try/finally in C++) ensure a concrete and explicit programming style.&lt;br /&gt;
&lt;br /&gt;
==Types==&lt;br /&gt;
&lt;br /&gt;
* Numbers are represented in Go as either Integers or Floating point numbers.&lt;br /&gt;
**Integers: Used to represent numbers without a decimal component. Different integers supported by Go are: uint8, uint16, uint32, uint64, int8, int16, int32, int64. Uint is used for unsigned integers and int for signed. 8,16, 32, 64 indicate the number of bits each type would use.&lt;br /&gt;
**Floating Point Integers: Used to support decimal components. Go supports float32 and float64 to represent floating point numbers and complex32 and complex64 to represent complex numbers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var x int32 =4&lt;br /&gt;
var y float32 = 4.5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* String: String litersals can be created using either double quotes(“Hello”) or back ticks(`Hello`). Strings have several operations associated them, for example one can find the length of the string or get a character at a specific index in a string.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
	fmt.Println(len(“Hello”)) // output: 5&lt;br /&gt;
	fmt.Println(“Hello”[1]) // output: 1&lt;br /&gt;
	fmt.Println(“Hello “+”Tom”) //output: Hello Tom&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Boolean: A 1 bit value is used to represent true or false.&lt;br /&gt;
&lt;br /&gt;
==Variables and Constants==&lt;br /&gt;
*Variabes in Go are indicated using the var keyword. Example: var x string=”hello” . They can also be shorthanded as x:=”hello” .&lt;br /&gt;
*The variable names should begin with a letter and can contain letters, digits or underscore character.&lt;br /&gt;
*The scope of the variable is the block in which it is defined and an attempt to access it outside the block would result in an error on running the program.&lt;br /&gt;
*Go provides support for constants (i.e. variables whose value can not be changed), using the const keyword. Example: const temp string = “Hello”&lt;br /&gt;
*In Go one can define multiple variables(or constants) using the following syntax:&lt;br /&gt;
    var(&lt;br /&gt;
         t1 =1&lt;br /&gt;
         t2=2&lt;br /&gt;
         t3=3&lt;br /&gt;
        t4=4&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Control Structures==&lt;br /&gt;
*For: It is used for repeating a list of statement(s) multiple times. The example below is used for calculating sum of numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    i := 1&lt;br /&gt;
    sum := 0&lt;br /&gt;
&lt;br /&gt;
    for i &amp;lt;= 10 {&lt;br /&gt;
        sum = sum + i&lt;br /&gt;
        i = i + 1&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    fmt.Println(“Sum:” + sum)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the example above i is a loop counter variable and is used to ensure that sum of numbers from 1 to 10 is computed. It indicates the number of times the statements inside the for loop is to be executed. The statement following the keyword for should evaluate to either true or false. If it is evaluated to true the body of for is executed, else we come out of the for loop.&lt;br /&gt;
&lt;br /&gt;
*If: Used to execute a block of statement(s) based on the evaluation of an expression to either true or false. It can also have an else associated with it.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    if i % 2 == 0 {&lt;br /&gt;
        fmt.Println(i + ” is divisble by 2”)&lt;br /&gt;
    } else {&lt;br /&gt;
        fmt.Println(i + “is not divisible by 2”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Switch: The value of the expression following switch is evaluated and is compared against the different cases. Based on the matching case, the block following that case is executed. Switch also has a default case in situations when none of the cases are matching.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    // if op ==1 then so a+b&lt;br /&gt;
    // if op == 2 then do a-b&lt;br /&gt;
    // if op == 3 then do a*b&lt;br /&gt;
    // if op ==4 then do a/b&lt;br /&gt;
    // default print, invalid operator&lt;br /&gt;
&lt;br /&gt;
    op:= 1&lt;br /&gt;
    a=6&lt;br /&gt;
    b=7&lt;br /&gt;
    switch(op) {&lt;br /&gt;
        case 1: fmt.Println(a+b)&lt;br /&gt;
        case 2: fmt.Println(a-b)&lt;br /&gt;
        case 3: fmt.Println(a*b)&lt;br /&gt;
        case 4: fmt.Println(a/b)&lt;br /&gt;
        default: fmt.Println(“Invalid Operator”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Arrays, Slices and Maps==&lt;br /&gt;
&lt;br /&gt;
*Arrays: Numbered sequence of elements starting with index zero and each of the elements having a fixed length. The example below illustrates various operations performed on arrays in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
    var x[10] int&lt;br /&gt;
    x[99]=100&lt;br /&gt;
    fmt.Println(x)  //[0 0 ….. 0 100]&lt;br /&gt;
    fmt.Println(len(x)) //100&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Slices: &lt;br /&gt;
** It is a segment of an array.&lt;br /&gt;
** They have a length and are indexable.&lt;br /&gt;
**In case of a slice the size does not have to specified in the square bracket.&lt;br /&gt;
**Slices support two in-build functions: copy and append.&lt;br /&gt;
**The program below illustrates the different ways to create slices and use of copy and append.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    arr := [10] int {1,2,3,4,5,6,7,8,9,10}&lt;br /&gt;
    x := make([]int,10) // creates a slice [1...10]&lt;br /&gt;
    y := make([]int,10,10) //creates a slice [1...10]&lt;br /&gt;
    z := arr[0:10] //creates a slice [1...10]&lt;br /&gt;
    s1 := []int{1,2,3,4,5}&lt;br /&gt;
    s2 := append(s1, 6, 7)&lt;br /&gt;
    fmt.Println(s1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(s2) // [1,2,3,4,5,6,7]&lt;br /&gt;
    p1 := [] int{1,2,3,4,5}&lt;br /&gt;
    p2 :=make([]int, 4)&lt;br /&gt;
    copy(p2,p1)&lt;br /&gt;
    fmt.Println(p1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(p2)// [1,2,3,4]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Maps:&lt;br /&gt;
**A map is an unordered collection of key value pairs.&lt;br /&gt;
**Syntax: var x map[int] string , where int is the type of the key and string is the type of the value.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
    x := make(map[int]string)&lt;br /&gt;
    x[1] = one&lt;br /&gt;
    x[2] = two&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
&lt;br /&gt;
*In Go functions can take multiple inputs and return multiple outputs.&lt;br /&gt;
*Go supports a special kind of function called variadic function.&lt;br /&gt;
*Closure is the means by which functions can be created inside other function in Go.&lt;br /&gt;
*Go supports recursive functions.&lt;br /&gt;
*The example below the different types of function in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    display(“Hello World”)&lt;br /&gt;
    sum :=calculateSum(10,20)&lt;br /&gt;
    v1,v2=multipleValues()&lt;br /&gt;
    p=product(5,10,20)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function without return type&lt;br /&gt;
func display( s string) {&lt;br /&gt;
    fmt.Println(s)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns a single value&lt;br /&gt;
func calculateSum(a int, b int) int {&lt;br /&gt;
    c: = a + b&lt;br /&gt;
    return c&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns multiple values&lt;br /&gt;
func multipleValues(int, int) {&lt;br /&gt;
    return 1, 2&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Variadic function&lt;br /&gt;
func product(args ...int) int {&lt;br /&gt;
    p := 1&lt;br /&gt;
   for _, i := range args {&lt;br /&gt;
        p *= i&lt;br /&gt;
   }&lt;br /&gt;
   return p&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pointers==&lt;br /&gt;
It is used to reference a location in the memory where the value is stored rather than containing the value itself. Basic pointer operations in Go are illustrated in the example below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
//Different syntax for pointers&lt;br /&gt;
    &lt;br /&gt;
     ptr1 *int&lt;br /&gt;
     num :=10&lt;br /&gt;
     ptr1 = &amp;amp;num&lt;br /&gt;
     ptr2 := new(int)&lt;br /&gt;
     ptr2=&amp;amp;num&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Concurrency==&lt;br /&gt;
* Go ensures concurrency which allows sharing of state using communication mechanisms.&lt;br /&gt;
* Go provides support for multithreading and CPU parallelization.&lt;br /&gt;
* Go supports asynchrony i.e. allows operations like database and network I/O which are slow operations to occur in parallel along with other operations.&lt;br /&gt;
* A new lightweight process is created using go fund()&lt;br /&gt;
* Channel types are used for providing type safe and synchronized channels between different go routines.&lt;br /&gt;
&lt;br /&gt;
=Users of Go=&lt;br /&gt;
Apart from Google, which uses Go programming for some of its development, companies like [http://en.wikipedia.org/wiki/Dropbox_(service) Dropbox], [http://en.wikipedia.org/wiki/CloudFlare CloudFlare], [http://en.wikipedia.org/wiki/SoundCloud SoundCloud], The BBC, Novartis, Cloud Foundry also use Go programming.  &lt;br /&gt;
Dropbox server (running in the cloud) and desktop client software were primarily written in [http://en.wikipedia.org/wiki/Python_(programming_language) Python]. From mid-2013 Dropbox began migrating its backend infrastructure to Go.&lt;br /&gt;
Some of the open-source applications that are using Go programming are Docker, Flynn, PaaS, Juju, nsq, Doozer e.t.c .&amp;lt;ref name = &amp;quot;GoWIKI&amp;quot;&amp;gt;[http://en.wikipedia.org/wiki/Go_(programming_language), Wikipedia]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advantages&amp;lt;ref name=&amp;quot;csdn&amp;quot;&amp;gt; [http://blog.csdn.net/lymemoryzz/article/details/20960997 CSDN blog]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
 &lt;br /&gt;
*'''C Level Performance'''. golang is within a close margin of the performance level of C code (which is itself an extremely high performance language). It is certainly closer to the performance of native languages than other enterprise level languages such as Java, Scala, Erlang etc.&lt;br /&gt;
 &lt;br /&gt;
*'''Fast Compilation''' is one of the key advantages of Go language. The Golang compiler was designed to compile programs very quickly. Extremely large programs with massively high LOC counts compile seemingly instantly - after all, Golang was designed by Google to solve Google problems, and Google has big problems! At Google, code and CPU cores are both measured in the millions. Go provides a model for software construction that makes dependency analysis easy and avoids much of the overhead of C-style include files and libraries.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reduced compile time is a key improvement in the Go language&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      If A.go depends on B.go depends on C.go :&lt;br /&gt;
         Compile C.go, B.go then A.go normally (other languages)&lt;br /&gt;
         To compile A.go, compiler reads B.o not C.o (go)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At a large scale this should help in hugely speeding up&lt;br /&gt;
&lt;br /&gt;
Other advantages are      &lt;br /&gt;
* '''Concurrency Supported At Language Level'''. Concurrency is the ability to execute multiple computations simultaneously. In today's modern multicore and high-load computing environment, concurrency is a critical language feature, and one in which languages such as Java struggle immensely.&lt;br /&gt;
* By its design, Go proposes an approach for the construction of system software on '''multicore machines'''.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
* Google have summed things up nicely with their motto: '''Don't communicate by sharing memory, share memory by communicating'''.Channels allow you to pass references to data structures between goroutines. If you consider this as passing around ownership of the data (the ability to read and write it), they become a powerful and expressive synchronization mechanism.  &lt;br /&gt;
* '''Go's type system has no hierarchy''', so no time is spent defining the relationships between types. Also, although Go has static types, the language attempts to make types feel lighter weight than in typical Object Oriented languages.&lt;br /&gt;
* '''Garbage Collection is much better'''. In C and C++, programmers spend a lot of time and energy on allocating and freeing memory. The designers of Go wanted to remove that complication, and ensure Go programmers could concentrate on more productive tasks. As such, they implemented garbage collection. As a developer, this is a very good thing. Sure, garbage collection comes with its own set of issues, but those are dealt with by the language implementer while the programmer is free to reap the other many benefits of Go.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
*Go is still an experimental language subject to change.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;&amp;gt;[http://stackoverflow.com/questions/2198529/what-are-the-advantages-and-disadvantages-of-go-programming-language stackoverflow]&amp;lt;/ref&amp;gt;&lt;br /&gt;
*Go's not very usable on Windows yet.&lt;br /&gt;
*The packages distributed with Go are pretty useful, but there are still some libraries you'll miss. Most notably a UI toolkit.&lt;br /&gt;
*There is no support for generics in Go, although there are many discussions around it.&lt;br /&gt;
*Confusing Semantics Of Exported Identifiers&amp;lt;ref name = &amp;quot;Limitations2&amp;quot;&amp;gt;&lt;br /&gt;
[https://functionwhatwhat.com/go’s-type-system-is-an-embarrassment functionwhatwhat ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=88573</id>
		<title>CSC/ECE 517 Fall 2014/ch1a 10 hu</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=88573"/>
		<updated>2014-09-26T00:49:50Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Comparison between Go Programming and C++ Programming language KTH comparisonQuora comparisonscriptol */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==''' Go Programming Language''' ==&lt;br /&gt;
'''Go''', also commonly referred to as '''golang''', is a compiled, concurrent, garbage-collected, statically typed language developed at [http://en.wikipedia.org/wiki/Google Google]. It was developed by [http://en.wikipedia.org/wiki/Robert_Griesemer Robert Griesemer], [http://en.wikipedia.org/wiki/Rob_Pike Rob Pike] and [http://en.wikipedia.org/wiki/Ken_Thompson Ken Thompson] in 2007. It was announced in November 2009 and is currently being used in many production systems at Google. It is an open source project. The syntax is loosely derived from that of [http://en.wikipedia.org/wiki/C_(programming_language) C programming language], adding [http://en.wikipedia.org/wiki/Garbage_collection_(computer_science) garbage collection], type safety, some dynamic-typing capabilities. Additional built-in types such as variable-length arrays and key-value maps, and a large standard library are also supported. Different operating systems like Linux, Microsoft Windows, Mac OS X are suported by [https://golang.org/cmd/gc Gc] compiler of Go.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
&lt;br /&gt;
Go programming started of as a research project by Robert Griesemer, Rob Pike and Ken Thompson. They felt that there was no new system focused programming language that has come up in the last decade till 2008, while there were other developments like increase in the size of libraries, dominance of networking , client server focus, multi-core CPUs.&amp;lt;ref name = &amp;quot;Background 1&amp;quot;&amp;gt;[https://www.youtube.com/watch?v=rKnDgT73v8s Go Language Introduction speech]&amp;lt;/ref&amp;gt; So they wanted to come up with a new systems focused programming language that would address the above issues.&amp;lt;ref name=&amp;quot;BG2&amp;quot;&amp;gt;[http://techcrunch.com/2009/11/10/google-go-language TechCrunch]&amp;lt;/ref&amp;gt; They started sketching the goals for a new language on the white board on September 21, 2007. Within a few days the goals had settled into a plan to do something and a fair idea of what it would be. Design continued part-time in parallel with unrelated work.&lt;br /&gt;
By January 2008, Ken had started work on a compiler with which to explore ideas; it generated C code as its output. By mid-year the language had become a full-time project and had settled enough to attempt a production compiler. In May 2008, [http://research.google.com/pubs/author37504.html Ian Taylor] independently started on a [http://en.wikipedia.org/wiki/GNU_Compiler_Collection GCC] front end for Go using the draft specification.  [http://russ.cox.usesthis.com/ Russ Cox] joined in late 2008 and helped move the language and libraries from prototype to reality.&lt;br /&gt;
Go became a public [http://en.wikipedia.org/wiki/Open_source open source project] on November 10, 2009. Many people from the community have contributed ideas, discussions, and code.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Compilers and Runtime support=&lt;br /&gt;
&lt;br /&gt;
There are two Go compiler implementations, [https://golang.org/cmd/gc Gc] (the 6g program and friends) and [http://blog.golang.org/gccgo-in-gcc-471 gccgo ]. Gc uses a different calling convention and linker. It can therefore only be linked with C programs using the same convention. Gccgo is a GCC front-end that can be linked with GCC-compiled C or C++ programs.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cgo program provides the mechanism for a “foreign function interface” to allow safe calling of C libraries from Go code. [http://en.wikipedia.org/wiki/SWIG SWIG] extends this capability to C++ libraries. &lt;br /&gt;
&lt;br /&gt;
Again due to bootstrapping issues, the run-time code is mostly in C (with a tiny bit of assembler) although Go is capable of implementing most of it now. Gccgo's run-time support uses glibc. Gc uses a custom library to keep the footprint under control; it is compiled with a version of the [http://plan9.bell-labs.com/sys/doc/compiler.html Plan 9 C compiler] that supports resizable stacks for goroutines. The gccgo compiler implements these on Linux only, using a technique called segmented stacks, supported by recent modifications to the gold linker.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find all resources needed to compile and run Go Language here http://go-lang.cat-v.org/&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
 &lt;br /&gt;
Programming today involves too much bookkeeping, repetition, and clerical work. As Dick Gabriel says, “Old programs read like quiet conversations between a well-spoken research worker and a well-studied mechanical colleague, not as a debate with a compiler. Who'd have guessed sophistication bought such noise?” The sophistication is worthwhile—no one wants to go back to the old languages—but can it be more quietly achieved?&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Go attempts to reduce the amount of typing in both senses of the word. Throughout its design, &lt;br /&gt;
*They have tried to reduce clutter and complexity. &lt;br /&gt;
*There are no forward declarations and no header files. everything is declared exactly once. &lt;br /&gt;
*Initialization is expressive, automatic, and easy to use. &lt;br /&gt;
*Syntax is clean and light on keywords. Stuttering (foo.Foo* myFoo = new(foo.Foo)) is reduced by simple type derivation using the := declare-and-initialize construct. &lt;br /&gt;
*And perhaps most radically, there is no type hierarchy. They don't have to announce their relationships.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
These simplifications allow Go to be expressive yet comprehensible without sacrificing, well, sophistication.&lt;br /&gt;
Another important principle is to keep the concepts orthogonal. Methods can be implemented for any type; structures represent data while interfaces represent abstraction; and so on. Orthogonality makes it easier to understand what happens when things combine.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Comparison between Go Programming and C++ Programming language &amp;lt;ref name=&amp;quot;KTH&amp;quot;&amp;gt;[http://www.csc.kth.se/utbildning/kth/kurser/DD143X/dkand11/Group9Alexander/Joakim_Anneback_Johan_Stjernberg.finalreport.2.pdf KTH comparison]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;quora&amp;quot;&amp;gt;[http://www.quora.com/How-does-Go-compare-to-C++-and-Java Quora comparison]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;Scriptol&amp;quot;&amp;gt;[http://www.scriptol.com/programming/go.php scriptol]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
Go programming language was developed to run as fast as C++ programs while adding a lot of other modern day features. Some of the key differeneces are listed below&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;2&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Points of Comparison&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Go Programming Language&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | C++ Programming Language&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Primary Focus'''&lt;br /&gt;
|| Go focuses on garbage collection, concurrency and compiling quickly&lt;br /&gt;
|| C++ focuses on inheritance, generic types and pointer arithmetics.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Variable Sizes'''&lt;br /&gt;
|| Machine-independent types are now included without an import needed:  int8, int16, int32, int64, uint8, etc.&lt;br /&gt;
|| Machine-dependent variable sizes&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Class Hierarchies'''&lt;br /&gt;
|| Inheritance is not supported , but with the traditional structures with plain old functions and namespaces, is a MUCH &lt;br /&gt;
better, more flexible approach that leads to better, more maintainable code. &lt;br /&gt;
|| Inheritance is supported but it has its own share of problems like diamond inheritance, virtual inheritance and normal inheritance.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Function overloading'''&lt;br /&gt;
|| Not present in Go because it simplifies dispatch.	&lt;br /&gt;
|| Present in C++.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Genrics'''&lt;br /&gt;
|| Go does not currently support generic types. However, it does support objects without a type using the empty interface.&lt;br /&gt;
|| C++ on the other hand has support for generic types. Generic programming is supported by the use of function templates, class templates and, in some cases, specialized templates in C++.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Multithreading'''&lt;br /&gt;
|| Goroutines are Go's model of threads/coroutines. Each new goroutine runs in parallel with the current computation, in &amp;quot;the same address space. Goroutines are cheap and developers need not to &lt;br /&gt;
worry about the stack size.&lt;br /&gt;
|| In contrast, there is currently no built-in way to manage threads in C++, although the feature is expected in the upcoming new standard and is already today possible using third-party libraries. &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Garbage Collection'''&lt;br /&gt;
|| Go uses garbage collection for memory management, which means that if frees the programmer completely from keeping a track on the memory used.&lt;br /&gt;
|| C++ does not have any garbage collection and hence relies heavily on that the programmer knows what he or she is doing.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Language Design&amp;lt;ref name = &amp;quot;GoLang Book&amp;quot;&amp;gt;[http://www.golang-book.com, GoLang Book]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 package main //line 1&lt;br /&gt;
&lt;br /&gt;
   import “fmt”  //line 2&lt;br /&gt;
&lt;br /&gt;
   func main() {  //line 3&lt;br /&gt;
&lt;br /&gt;
       fmt.Println(“Hello World”) //line 4&lt;br /&gt;
&lt;br /&gt;
   } //line 5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Line1 specifies package declaration. Package is used to organize and reuse code. Line 2 is used for including the package “fmt” which is used for formatting input and output. Line 3 to 5 defines the function main. main is the function which is called when a program is executed. Println function in fmt is used to display content to the console i.e in this example Hello World is displayed in the console on executing the program.&lt;br /&gt;
&lt;br /&gt;
==Code Conventions and Style==&lt;br /&gt;
&lt;br /&gt;
* Go fmt tool is used to automatically standardize indentation, spaces and surface-level code details. go vet and go link are perform checking automatically.&lt;br /&gt;
* Using tools and libraries provided in Go, there are standard approaches for API documentation(go doc), testing(go test), building(go build) and package management(go get).&lt;br /&gt;
* Syntax prevents any kind of cyclic dependencies.&lt;br /&gt;
* Unused variables and imports are not allowed.&lt;br /&gt;
* Elimination of functional programming constructs (such as map and try/finally in C++) ensure a concrete and explicit programming style.&lt;br /&gt;
&lt;br /&gt;
==Types==&lt;br /&gt;
&lt;br /&gt;
* Numbers are represented in Go as either Integers or Floating point numbers.&lt;br /&gt;
**Integers: Used to represent numbers without a decimal component. Different integers supported by Go are: uint8, uint16, uint32, uint64, int8, int16, int32, int64. Uint is used for unsigned integers and int for signed. 8,16, 32, 64 indicate the number of bits each type would use.&lt;br /&gt;
**Floating Point Integers: Used to support decimal components. Go supports float32 and float64 to represent floating point numbers and complex32 and complex64 to represent complex numbers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var x int32 =4&lt;br /&gt;
var y float32 = 4.5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* String: String litersals can be created using either double quotes(“Hello”) or back ticks(`Hello`). Strings have several operations associated them, for example one can find the length of the string or get a character at a specific index in a string.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
	fmt.Println(len(“Hello”)) // output: 5&lt;br /&gt;
	fmt.Println(“Hello”[1]) // output: 1&lt;br /&gt;
	fmt.Println(“Hello “+”Tom”) //output: Hello Tom&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Boolean: A 1 bit value is used to represent true or false.&lt;br /&gt;
&lt;br /&gt;
==Variables and Constants==&lt;br /&gt;
*Variabes in Go are indicated using the var keyword. Example: var x string=”hello” . They can also be shorthanded as x:=”hello” .&lt;br /&gt;
*The variable names should begin with a letter and can contain letters, digits or underscore character.&lt;br /&gt;
*The scope of the variable is the block in which it is defined and an attempt to access it outside the block would result in an error on running the program.&lt;br /&gt;
*Go provides support for constants (i.e. variables whose value can not be changed), using the const keyword. Example: const temp string = “Hello”&lt;br /&gt;
*In Go one can define multiple variables(or constants) using the following syntax:&lt;br /&gt;
    var(&lt;br /&gt;
         t1 =1&lt;br /&gt;
         t2=2&lt;br /&gt;
         t3=3&lt;br /&gt;
        t4=4&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Control Structures==&lt;br /&gt;
*For: It is used for repeating a list of statement(s) multiple times. The example below is used for calculating sum of numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    i := 1&lt;br /&gt;
    sum := 0&lt;br /&gt;
&lt;br /&gt;
    for i &amp;lt;= 10 {&lt;br /&gt;
        sum = sum + i&lt;br /&gt;
        i = i + 1&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    fmt.Println(“Sum:” + sum)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the example above i is a loop counter variable and is used to ensure that sum of numbers from 1 to 10 is computed. It indicates the number of times the statements inside the for loop is to be executed. The statement following the keyword for should evaluate to either true or false. If it is evaluated to true the body of for is executed, else we come out of the for loop.&lt;br /&gt;
&lt;br /&gt;
*If: Used to execute a block of statement(s) based on the evaluation of an expression to either true or false. It can also have an else associated with it.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    if i % 2 == 0 {&lt;br /&gt;
        fmt.Println(i + ” is divisble by 2”)&lt;br /&gt;
    } else {&lt;br /&gt;
        fmt.Println(i + “is not divisible by 2”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Switch: The value of the expression following switch is evaluated and is compared against the different cases. Based on the matching case, the block following that case is executed. Switch also has a default case in situations when none of the cases are matching.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    // if op ==1 then so a+b&lt;br /&gt;
    // if op == 2 then do a-b&lt;br /&gt;
    // if op == 3 then do a*b&lt;br /&gt;
    // if op ==4 then do a/b&lt;br /&gt;
    // default print, invalid operator&lt;br /&gt;
&lt;br /&gt;
    op:= 1&lt;br /&gt;
    a=6&lt;br /&gt;
    b=7&lt;br /&gt;
    switch(op) {&lt;br /&gt;
        case 1: fmt.Println(a+b)&lt;br /&gt;
        case 2: fmt.Println(a-b)&lt;br /&gt;
        case 3: fmt.Println(a*b)&lt;br /&gt;
        case 4: fmt.Println(a/b)&lt;br /&gt;
        default: fmt.Println(“Invalid Operator”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Arrays, Slices and Maps==&lt;br /&gt;
&lt;br /&gt;
*Arrays: Numbered sequence of elements starting with index zero and each of the elements having a fixed length. The example below illustrates various operations performed on arrays in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
    var x[10] int&lt;br /&gt;
    x[99]=100&lt;br /&gt;
    fmt.Println(x)  //[0 0 ….. 0 100]&lt;br /&gt;
    fmt.Println(len(x)) //100&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Slices: &lt;br /&gt;
** It is a segment of an array.&lt;br /&gt;
** They have a length and are indexable.&lt;br /&gt;
**In case of a slice the size does not have to specified in the square bracket.&lt;br /&gt;
**Slices support two in-build functions: copy and append.&lt;br /&gt;
**The program below illustrates the different ways to create slices and use of copy and append.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    arr := [10] int {1,2,3,4,5,6,7,8,9,10}&lt;br /&gt;
    x := make([]int,10) // creates a slice [1...10]&lt;br /&gt;
    y := make([]int,10,10) //creates a slice [1...10]&lt;br /&gt;
    z := arr[0:10] //creates a slice [1...10]&lt;br /&gt;
    s1 := []int{1,2,3,4,5}&lt;br /&gt;
    s2 := append(s1, 6, 7)&lt;br /&gt;
    fmt.Println(s1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(s2) // [1,2,3,4,5,6,7]&lt;br /&gt;
    p1 := [] int{1,2,3,4,5}&lt;br /&gt;
    p2 :=make([]int, 4)&lt;br /&gt;
    copy(p2,p1)&lt;br /&gt;
    fmt.Println(p1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(p2)// [1,2,3,4]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Maps:&lt;br /&gt;
**A map is an unordered collection of key value pairs.&lt;br /&gt;
**Syntax: var x map[int] string , where int is the type of the key and string is the type of the value.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
    x := make(map[int]string)&lt;br /&gt;
    x[1] = one&lt;br /&gt;
    x[2] = two&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
&lt;br /&gt;
*In Go functions can take multiple inputs and return multiple outputs.&lt;br /&gt;
*Go supports a special kind of function called variadic function.&lt;br /&gt;
*Closure is the means by which functions can be created inside other function in Go.&lt;br /&gt;
*Go supports recursive functions.&lt;br /&gt;
*The example below the different types of function in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    display(“Hello World”)&lt;br /&gt;
    sum :=calculateSum(10,20)&lt;br /&gt;
    v1,v2=multipleValues()&lt;br /&gt;
    p=product(5,10,20)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function without return type&lt;br /&gt;
func display( s string) {&lt;br /&gt;
    fmt.Println(s)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns a single value&lt;br /&gt;
func calculateSum(a int, b int) int {&lt;br /&gt;
    c: = a + b&lt;br /&gt;
    return c&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns multiple values&lt;br /&gt;
func multipleValues(int, int) {&lt;br /&gt;
    return 1, 2&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Variadic function&lt;br /&gt;
func product(args ...int) int {&lt;br /&gt;
    p := 1&lt;br /&gt;
   for _, i := range args {&lt;br /&gt;
        p *= i&lt;br /&gt;
   }&lt;br /&gt;
   return p&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pointers==&lt;br /&gt;
It is used to reference a location in the memory where the value is stored rather than containing the value itself. Basic pointer operations in Go are illustrated in the example below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
//Different syntax for pointers&lt;br /&gt;
    &lt;br /&gt;
     ptr1 *int&lt;br /&gt;
     num :=10&lt;br /&gt;
     ptr1 = &amp;amp;num&lt;br /&gt;
     ptr2 := new(int)&lt;br /&gt;
     ptr2=&amp;amp;num&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Concurrency==&lt;br /&gt;
* Go ensures concurrency which allows sharing of state using communication mechanisms.&lt;br /&gt;
* Go provides support for multithreading and CPU parallelization.&lt;br /&gt;
* Go supports asynchrony i.e. allows operations like database and network I/O which are slow operations to occur in parallel along with other operations.&lt;br /&gt;
* A new lightweight process is created using go fund()&lt;br /&gt;
* Channel types are used for providing type safe and synchronized channels between different go routines.&lt;br /&gt;
&lt;br /&gt;
=Users of Go=&lt;br /&gt;
Apart from Google, which uses Go programming for some of its development, companies like [http://en.wikipedia.org/wiki/Dropbox_(service) Dropbox], [http://en.wikipedia.org/wiki/CloudFlare CloudFlare], [http://en.wikipedia.org/wiki/SoundCloud SoundCloud], The BBC, Novartis, Cloud Foundry also use Go programming.  &lt;br /&gt;
Dropbox server (running in the cloud) and desktop client software were primarily written in [http://en.wikipedia.org/wiki/Python_(programming_language) Python]. From mid-2013 Dropbox began migrating its backend infrastructure to Go.&lt;br /&gt;
Some of the open-source applications that are using Go programming are Docker, Flynn, PaaS, Juju, nsq, Doozer e.t.c .&amp;lt;ref name = &amp;quot;GoWIKI&amp;quot;&amp;gt;[http://en.wikipedia.org/wiki/Go_(programming_language), Wikipedia]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advantages&amp;lt;ref name=&amp;quot;csdn&amp;quot;&amp;gt; [http://blog.csdn.net/lymemoryzz/article/details/20960997 CSDN blog]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
 &lt;br /&gt;
*'''C Level Performance'''. golang is within a close margin of the performance level of C code (which is itself an extremely high performance language). It is certainly closer to the performance of native languages than other enterprise level languages such as Java, Scala, Erlang etc.&lt;br /&gt;
 &lt;br /&gt;
*'''Fast Compilation''' is one of the key advantages of Go language. The Golang compiler was designed to compile programs very quickly. Extremely large programs with massively high LOC counts compile seemingly instantly - after all, Golang was designed by Google to solve Google problems, and Google has big problems! At Google, code and CPU cores are both measured in the millions. Go provides a model for software construction that makes dependency analysis easy and avoids much of the overhead of C-style include files and libraries.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reduced compile time is a key improvement in the Go language&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      If A.go depends on B.go depends on C.go :&lt;br /&gt;
         Compile C.go, B.go then A.go normally (other languages)&lt;br /&gt;
         To compile A.go, compiler reads B.o not C.o (go)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At a large scale this should help in hugely speeding up&lt;br /&gt;
&lt;br /&gt;
Other advantages are      &lt;br /&gt;
* '''Concurrency Supported At Language Level'''. Concurrency is the ability to execute multiple computations simultaneously. In today's modern multicore and high-load computing environment, concurrency is a critical language feature, and one in which languages such as Java struggle immensely.&lt;br /&gt;
* By its design, Go proposes an approach for the construction of system software on '''multicore machines'''.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
* Google have summed things up nicely with their motto: '''Don't communicate by sharing memory, share memory by communicating'''.Channels allow you to pass references to data structures between goroutines. If you consider this as passing around ownership of the data (the ability to read and write it), they become a powerful and expressive synchronization mechanism.  &lt;br /&gt;
* '''Go's type system has no hierarchy''', so no time is spent defining the relationships between types. Also, although Go has static types, the language attempts to make types feel lighter weight than in typical Object Oriented languages.&lt;br /&gt;
* '''Garbage Collection is much better'''. In C and C++, programmers spend a lot of time and energy on allocating and freeing memory. The designers of Go wanted to remove that complication, and ensure Go programmers could concentrate on more productive tasks. As such, they implemented garbage collection. As a developer, this is a very good thing. Sure, garbage collection comes with its own set of issues, but those are dealt with by the language implementer while the programmer is free to reap the other many benefits of Go.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
*Go is still an experimental language subject to change.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;&amp;gt;[http://stackoverflow.com/questions/2198529/what-are-the-advantages-and-disadvantages-of-go-programming-language stackoverflow]&amp;lt;/ref&amp;gt;&lt;br /&gt;
*Go's not very usable on Windows yet.&lt;br /&gt;
*The packages distributed with Go are pretty useful, but there are still some libraries you'll miss. Most notably a UI toolkit.&lt;br /&gt;
*There is no support for generics in Go, although there are many discussions around it.&lt;br /&gt;
*Confusing Semantics Of Exported Identifiers&amp;lt;ref name = &amp;quot;Limitations2&amp;quot;&amp;gt;&lt;br /&gt;
[https://functionwhatwhat.com/go’s-type-system-is-an-embarrassment functionwhatwhat ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=88570</id>
		<title>CSC/ECE 517 Fall 2014/ch1a 10 hu</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=88570"/>
		<updated>2014-09-26T00:47:21Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==''' Go Programming Language''' ==&lt;br /&gt;
'''Go''', also commonly referred to as '''golang''', is a compiled, concurrent, garbage-collected, statically typed language developed at [http://en.wikipedia.org/wiki/Google Google]. It was developed by [http://en.wikipedia.org/wiki/Robert_Griesemer Robert Griesemer], [http://en.wikipedia.org/wiki/Rob_Pike Rob Pike] and [http://en.wikipedia.org/wiki/Ken_Thompson Ken Thompson] in 2007. It was announced in November 2009 and is currently being used in many production systems at Google. It is an open source project. The syntax is loosely derived from that of [http://en.wikipedia.org/wiki/C_(programming_language) C programming language], adding [http://en.wikipedia.org/wiki/Garbage_collection_(computer_science) garbage collection], type safety, some dynamic-typing capabilities. Additional built-in types such as variable-length arrays and key-value maps, and a large standard library are also supported. Different operating systems like Linux, Microsoft Windows, Mac OS X are suported by [https://golang.org/cmd/gc Gc] compiler of Go.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
&lt;br /&gt;
Go programming started of as a research project by Robert Griesemer, Rob Pike and Ken Thompson. They felt that there was no new system focused programming language that has come up in the last decade till 2008, while there were other developments like increase in the size of libraries, dominance of networking , client server focus, multi-core CPUs.&amp;lt;ref name = &amp;quot;Background 1&amp;quot;&amp;gt;[https://www.youtube.com/watch?v=rKnDgT73v8s Go Language Introduction speech]&amp;lt;/ref&amp;gt; So they wanted to come up with a new systems focused programming language that would address the above issues.&amp;lt;ref name=&amp;quot;BG2&amp;quot;&amp;gt;[http://techcrunch.com/2009/11/10/google-go-language TechCrunch]&amp;lt;/ref&amp;gt; They started sketching the goals for a new language on the white board on September 21, 2007. Within a few days the goals had settled into a plan to do something and a fair idea of what it would be. Design continued part-time in parallel with unrelated work.&lt;br /&gt;
By January 2008, Ken had started work on a compiler with which to explore ideas; it generated C code as its output. By mid-year the language had become a full-time project and had settled enough to attempt a production compiler. In May 2008, [http://research.google.com/pubs/author37504.html Ian Taylor] independently started on a [http://en.wikipedia.org/wiki/GNU_Compiler_Collection GCC] front end for Go using the draft specification.  [http://russ.cox.usesthis.com/ Russ Cox] joined in late 2008 and helped move the language and libraries from prototype to reality.&lt;br /&gt;
Go became a public [http://en.wikipedia.org/wiki/Open_source open source project] on November 10, 2009. Many people from the community have contributed ideas, discussions, and code.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Compilers and Runtime support=&lt;br /&gt;
&lt;br /&gt;
There are two Go compiler implementations, [https://golang.org/cmd/gc Gc] (the 6g program and friends) and [http://blog.golang.org/gccgo-in-gcc-471 gccgo ]. Gc uses a different calling convention and linker. It can therefore only be linked with C programs using the same convention. Gccgo is a GCC front-end that can be linked with GCC-compiled C or C++ programs.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cgo program provides the mechanism for a “foreign function interface” to allow safe calling of C libraries from Go code. [http://en.wikipedia.org/wiki/SWIG SWIG] extends this capability to C++ libraries. &lt;br /&gt;
&lt;br /&gt;
Again due to bootstrapping issues, the run-time code is mostly in C (with a tiny bit of assembler) although Go is capable of implementing most of it now. Gccgo's run-time support uses glibc. Gc uses a custom library to keep the footprint under control; it is compiled with a version of the [http://plan9.bell-labs.com/sys/doc/compiler.html Plan 9 C compiler] that supports resizable stacks for goroutines. The gccgo compiler implements these on Linux only, using a technique called segmented stacks, supported by recent modifications to the gold linker.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find all resources needed to compile and run Go Language here http://go-lang.cat-v.org/&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
 &lt;br /&gt;
Programming today involves too much bookkeeping, repetition, and clerical work. As Dick Gabriel says, “Old programs read like quiet conversations between a well-spoken research worker and a well-studied mechanical colleague, not as a debate with a compiler. Who'd have guessed sophistication bought such noise?” The sophistication is worthwhile—no one wants to go back to the old languages—but can it be more quietly achieved?&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Go attempts to reduce the amount of typing in both senses of the word. Throughout its design, &lt;br /&gt;
*They have tried to reduce clutter and complexity. &lt;br /&gt;
*There are no forward declarations and no header files. everything is declared exactly once. &lt;br /&gt;
*Initialization is expressive, automatic, and easy to use. &lt;br /&gt;
*Syntax is clean and light on keywords. Stuttering (foo.Foo* myFoo = new(foo.Foo)) is reduced by simple type derivation using the := declare-and-initialize construct. &lt;br /&gt;
*And perhaps most radically, there is no type hierarchy. They don't have to announce their relationships.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
These simplifications allow Go to be expressive yet comprehensible without sacrificing, well, sophistication.&lt;br /&gt;
Another important principle is to keep the concepts orthogonal. Methods can be implemented for any type; structures represent data while interfaces represent abstraction; and so on. Orthogonality makes it easier to understand what happens when things combine.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Comparison between Go Programming and C++ Programming language &amp;lt;ref name=&amp;quot;KTH&amp;quot;&amp;gt;[http://www.csc.kth.se/utbildning/kth/kurser/DD143X/dkand11/Group9Alexander/Joakim_Anneback_Johan_Stjernberg.finalreport.2.pdf KTH comparison]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;quora&amp;quot;&amp;gt;[http://www.quora.com/How-does-Go-compare-to-C++-and-Java Quora comparison]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;Scriptol&amp;quot;&amp;gt;[http://www.scriptol.com/programming/go.php scriptol]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
Go programming language was developed to run as fast of C++ programs while adding a lot of other modern day features. Some of the key differeneces are listed below&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;2&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Points of Comparison&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Go Programming Language&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | C++ Programming Language&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Primary Focus'''&lt;br /&gt;
|| Go focuses on garbage collection, concurrency and compiling quickly&lt;br /&gt;
|| C++ focuses on inheritance, generic types and pointer arithmetics.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Variable Sizes'''&lt;br /&gt;
|| Machine-independent types are now included without an import needed:  int8, int16, int32, int64, uint8, etc.&lt;br /&gt;
|| Machine-dependent variable sizes&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Class Hierarchies'''&lt;br /&gt;
|| Inheritance is not supported , but with the traditional structures with plain old functions and namespaces, is a MUCH &lt;br /&gt;
better, more flexible approach that leads to better, more maintainable code. &lt;br /&gt;
|| Inheritance is supported but it has its own share of problems like diamond inheritance, virtual inheritance and normal inheritance.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Function overloading'''&lt;br /&gt;
|| Not present in Go because it simplifies dispatch.	&lt;br /&gt;
|| Present in C++.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Genrics'''&lt;br /&gt;
|| Go does not currently support generic types. However, it does support objects without a type using the empty interface.&lt;br /&gt;
|| C++ on the other hand has support for generic types. Generic programming is supported by the use of function templates, class templates and, in some cases, specialized templates in C++.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Multithreading'''&lt;br /&gt;
|| Goroutines are Go's model of threads/coroutines. Each new goroutine runs in parallel with the current computation, in &amp;quot;the same address space. Goroutines are cheap and developers need not to &lt;br /&gt;
worry about the stack size.&lt;br /&gt;
|| In contrast, there is currently no built-in way to manage threads in C++, although the feature is expected in the upcoming new standard and is already today possible using third-party libraries. &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
'''Garbage Collection'''&lt;br /&gt;
|| Go uses garbage collection for memory management, which means that if frees the programmer completely from keeping a track on the memory used.&lt;br /&gt;
|| C++ does not have any garbage collection and hence relies heavily on that the programmer knows what he or she is doing.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Language Design&amp;lt;ref name = &amp;quot;GoLang Book&amp;quot;&amp;gt;[http://www.golang-book.com, GoLang Book]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 package main //line 1&lt;br /&gt;
&lt;br /&gt;
   import “fmt”  //line 2&lt;br /&gt;
&lt;br /&gt;
   func main() {  //line 3&lt;br /&gt;
&lt;br /&gt;
       fmt.Println(“Hello World”) //line 4&lt;br /&gt;
&lt;br /&gt;
   } //line 5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Line1 specifies package declaration. Package is used to organize and reuse code. Line 2 is used for including the package “fmt” which is used for formatting input and output. Line 3 to 5 defines the function main. main is the function which is called when a program is executed. Println function in fmt is used to display content to the console i.e in this example Hello World is displayed in the console on executing the program.&lt;br /&gt;
&lt;br /&gt;
==Code Conventions and Style==&lt;br /&gt;
&lt;br /&gt;
* Go fmt tool is used to automatically standardize indentation, spaces and surface-level code details. go vet and go link are perform checking automatically.&lt;br /&gt;
* Using tools and libraries provided in Go, there are standard approaches for API documentation(go doc), testing(go test), building(go build) and package management(go get).&lt;br /&gt;
* Syntax prevents any kind of cyclic dependencies.&lt;br /&gt;
* Unused variables and imports are not allowed.&lt;br /&gt;
* Elimination of functional programming constructs (such as map and try/finally in C++) ensure a concrete and explicit programming style.&lt;br /&gt;
&lt;br /&gt;
==Types==&lt;br /&gt;
&lt;br /&gt;
* Numbers are represented in Go as either Integers or Floating point numbers.&lt;br /&gt;
**Integers: Used to represent numbers without a decimal component. Different integers supported by Go are: uint8, uint16, uint32, uint64, int8, int16, int32, int64. Uint is used for unsigned integers and int for signed. 8,16, 32, 64 indicate the number of bits each type would use.&lt;br /&gt;
**Floating Point Integers: Used to support decimal components. Go supports float32 and float64 to represent floating point numbers and complex32 and complex64 to represent complex numbers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var x int32 =4&lt;br /&gt;
var y float32 = 4.5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* String: String litersals can be created using either double quotes(“Hello”) or back ticks(`Hello`). Strings have several operations associated them, for example one can find the length of the string or get a character at a specific index in a string.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
	fmt.Println(len(“Hello”)) // output: 5&lt;br /&gt;
	fmt.Println(“Hello”[1]) // output: 1&lt;br /&gt;
	fmt.Println(“Hello “+”Tom”) //output: Hello Tom&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Boolean: A 1 bit value is used to represent true or false.&lt;br /&gt;
&lt;br /&gt;
==Variables and Constants==&lt;br /&gt;
*Variabes in Go are indicated using the var keyword. Example: var x string=”hello” . They can also be shorthanded as x:=”hello” .&lt;br /&gt;
*The variable names should begin with a letter and can contain letters, digits or underscore character.&lt;br /&gt;
*The scope of the variable is the block in which it is defined and an attempt to access it outside the block would result in an error on running the program.&lt;br /&gt;
*Go provides support for constants (i.e. variables whose value can not be changed), using the const keyword. Example: const temp string = “Hello”&lt;br /&gt;
*In Go one can define multiple variables(or constants) using the following syntax:&lt;br /&gt;
    var(&lt;br /&gt;
         t1 =1&lt;br /&gt;
         t2=2&lt;br /&gt;
         t3=3&lt;br /&gt;
        t4=4&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Control Structures==&lt;br /&gt;
*For: It is used for repeating a list of statement(s) multiple times. The example below is used for calculating sum of numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    i := 1&lt;br /&gt;
    sum := 0&lt;br /&gt;
&lt;br /&gt;
    for i &amp;lt;= 10 {&lt;br /&gt;
        sum = sum + i&lt;br /&gt;
        i = i + 1&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    fmt.Println(“Sum:” + sum)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the example above i is a loop counter variable and is used to ensure that sum of numbers from 1 to 10 is computed. It indicates the number of times the statements inside the for loop is to be executed. The statement following the keyword for should evaluate to either true or false. If it is evaluated to true the body of for is executed, else we come out of the for loop.&lt;br /&gt;
&lt;br /&gt;
*If: Used to execute a block of statement(s) based on the evaluation of an expression to either true or false. It can also have an else associated with it.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    if i % 2 == 0 {&lt;br /&gt;
        fmt.Println(i + ” is divisble by 2”)&lt;br /&gt;
    } else {&lt;br /&gt;
        fmt.Println(i + “is not divisible by 2”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Switch: The value of the expression following switch is evaluated and is compared against the different cases. Based on the matching case, the block following that case is executed. Switch also has a default case in situations when none of the cases are matching.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    // if op ==1 then so a+b&lt;br /&gt;
    // if op == 2 then do a-b&lt;br /&gt;
    // if op == 3 then do a*b&lt;br /&gt;
    // if op ==4 then do a/b&lt;br /&gt;
    // default print, invalid operator&lt;br /&gt;
&lt;br /&gt;
    op:= 1&lt;br /&gt;
    a=6&lt;br /&gt;
    b=7&lt;br /&gt;
    switch(op) {&lt;br /&gt;
        case 1: fmt.Println(a+b)&lt;br /&gt;
        case 2: fmt.Println(a-b)&lt;br /&gt;
        case 3: fmt.Println(a*b)&lt;br /&gt;
        case 4: fmt.Println(a/b)&lt;br /&gt;
        default: fmt.Println(“Invalid Operator”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Arrays, Slices and Maps==&lt;br /&gt;
&lt;br /&gt;
*Arrays: Numbered sequence of elements starting with index zero and each of the elements having a fixed length. The example below illustrates various operations performed on arrays in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
    var x[10] int&lt;br /&gt;
    x[99]=100&lt;br /&gt;
    fmt.Println(x)  //[0 0 ….. 0 100]&lt;br /&gt;
    fmt.Println(len(x)) //100&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Slices: &lt;br /&gt;
** It is a segment of an array.&lt;br /&gt;
** They have a length and are indexable.&lt;br /&gt;
**In case of a slice the size does not have to specified in the square bracket.&lt;br /&gt;
**Slices support two in-build functions: copy and append.&lt;br /&gt;
**The program below illustrates the different ways to create slices and use of copy and append.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    arr := [10] int {1,2,3,4,5,6,7,8,9,10}&lt;br /&gt;
    x := make([]int,10) // creates a slice [1...10]&lt;br /&gt;
    y := make([]int,10,10) //creates a slice [1...10]&lt;br /&gt;
    z := arr[0:10] //creates a slice [1...10]&lt;br /&gt;
    s1 := []int{1,2,3,4,5}&lt;br /&gt;
    s2 := append(s1, 6, 7)&lt;br /&gt;
    fmt.Println(s1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(s2) // [1,2,3,4,5,6,7]&lt;br /&gt;
    p1 := [] int{1,2,3,4,5}&lt;br /&gt;
    p2 :=make([]int, 4)&lt;br /&gt;
    copy(p2,p1)&lt;br /&gt;
    fmt.Println(p1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(p2)// [1,2,3,4]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Maps:&lt;br /&gt;
**A map is an unordered collection of key value pairs.&lt;br /&gt;
**Syntax: var x map[int] string , where int is the type of the key and string is the type of the value.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
    x := make(map[int]string)&lt;br /&gt;
    x[1] = one&lt;br /&gt;
    x[2] = two&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
&lt;br /&gt;
*In Go functions can take multiple inputs and return multiple outputs.&lt;br /&gt;
*Go supports a special kind of function called variadic function.&lt;br /&gt;
*Closure is the means by which functions can be created inside other function in Go.&lt;br /&gt;
*Go supports recursive functions.&lt;br /&gt;
*The example below the different types of function in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    display(“Hello World”)&lt;br /&gt;
    sum :=calculateSum(10,20)&lt;br /&gt;
    v1,v2=multipleValues()&lt;br /&gt;
    p=product(5,10,20)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function without return type&lt;br /&gt;
func display( s string) {&lt;br /&gt;
    fmt.Println(s)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns a single value&lt;br /&gt;
func calculateSum(a int, b int) int {&lt;br /&gt;
    c: = a + b&lt;br /&gt;
    return c&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns multiple values&lt;br /&gt;
func multipleValues(int, int) {&lt;br /&gt;
    return 1, 2&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Variadic function&lt;br /&gt;
func product(args ...int) int {&lt;br /&gt;
    p := 1&lt;br /&gt;
   for _, i := range args {&lt;br /&gt;
        p *= i&lt;br /&gt;
   }&lt;br /&gt;
   return p&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pointers==&lt;br /&gt;
It is used to reference a location in the memory where the value is stored rather than containing the value itself. Basic pointer operations in Go are illustrated in the example below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
//Different syntax for pointers&lt;br /&gt;
    &lt;br /&gt;
     ptr1 *int&lt;br /&gt;
     num :=10&lt;br /&gt;
     ptr1 = &amp;amp;num&lt;br /&gt;
     ptr2 := new(int)&lt;br /&gt;
     ptr2=&amp;amp;num&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Concurrency==&lt;br /&gt;
* Go ensures concurrency which allows sharing of state using communication mechanisms.&lt;br /&gt;
* Go provides support for multithreading and CPU parallelization.&lt;br /&gt;
* Go supports asynchrony i.e. allows operations like database and network I/O which are slow operations to occur in parallel along with other operations.&lt;br /&gt;
* A new lightweight process is created using go fund()&lt;br /&gt;
* Channel types are used for providing type safe and synchronized channels between different go routines.&lt;br /&gt;
&lt;br /&gt;
=Users of Go=&lt;br /&gt;
Apart from Google, which uses Go programming for some of its development, companies like [http://en.wikipedia.org/wiki/Dropbox_(service) Dropbox], [http://en.wikipedia.org/wiki/CloudFlare CloudFlare], [http://en.wikipedia.org/wiki/SoundCloud SoundCloud], The BBC, Novartis, Cloud Foundry also use Go programming.  &lt;br /&gt;
Dropbox server (running in the cloud) and desktop client software were primarily written in [http://en.wikipedia.org/wiki/Python_(programming_language) Python]. From mid-2013 Dropbox began migrating its backend infrastructure to Go.&lt;br /&gt;
Some of the open-source applications that are using Go programming are Docker, Flynn, PaaS, Juju, nsq, Doozer e.t.c .&amp;lt;ref name = &amp;quot;GoWIKI&amp;quot;&amp;gt;[http://en.wikipedia.org/wiki/Go_(programming_language), Wikipedia]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advantages&amp;lt;ref name=&amp;quot;csdn&amp;quot;&amp;gt; [http://blog.csdn.net/lymemoryzz/article/details/20960997 CSDN blog]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
 &lt;br /&gt;
*'''C Level Performance'''. golang is within a close margin of the performance level of C code (which is itself an extremely high performance language). It is certainly closer to the performance of native languages than other enterprise level languages such as Java, Scala, Erlang etc.&lt;br /&gt;
 &lt;br /&gt;
*'''Fast Compilation''' is one of the key advantages of Go language. The Golang compiler was designed to compile programs very quickly. Extremely large programs with massively high LOC counts compile seemingly instantly - after all, Golang was designed by Google to solve Google problems, and Google has big problems! At Google, code and CPU cores are both measured in the millions. Go provides a model for software construction that makes dependency analysis easy and avoids much of the overhead of C-style include files and libraries.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reduced compile time is a key improvement in the Go language&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      If A.go depends on B.go depends on C.go :&lt;br /&gt;
         Compile C.go, B.go then A.go normally (other languages)&lt;br /&gt;
         To compile A.go, compiler reads B.o not C.o (go)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At a large scale this should help in hugely speeding up&lt;br /&gt;
&lt;br /&gt;
Other advantages are      &lt;br /&gt;
* '''Concurrency Supported At Language Level'''. Concurrency is the ability to execute multiple computations simultaneously. In today's modern multicore and high-load computing environment, concurrency is a critical language feature, and one in which languages such as Java struggle immensely.&lt;br /&gt;
* By its design, Go proposes an approach for the construction of system software on '''multicore machines'''.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
* Google have summed things up nicely with their motto: '''Don't communicate by sharing memory, share memory by communicating'''.Channels allow you to pass references to data structures between goroutines. If you consider this as passing around ownership of the data (the ability to read and write it), they become a powerful and expressive synchronization mechanism.  &lt;br /&gt;
* '''Go's type system has no hierarchy''', so no time is spent defining the relationships between types. Also, although Go has static types, the language attempts to make types feel lighter weight than in typical Object Oriented languages.&lt;br /&gt;
* '''Garbage Collection is much better'''. In C and C++, programmers spend a lot of time and energy on allocating and freeing memory. The designers of Go wanted to remove that complication, and ensure Go programmers could concentrate on more productive tasks. As such, they implemented garbage collection. As a developer, this is a very good thing. Sure, garbage collection comes with its own set of issues, but those are dealt with by the language implementer while the programmer is free to reap the other many benefits of Go.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
*Go is still an experimental language subject to change.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;&amp;gt;[http://stackoverflow.com/questions/2198529/what-are-the-advantages-and-disadvantages-of-go-programming-language stackoverflow]&amp;lt;/ref&amp;gt;&lt;br /&gt;
*Go's not very usable on Windows yet.&lt;br /&gt;
*The packages distributed with Go are pretty useful, but there are still some libraries you'll miss. Most notably a UI toolkit.&lt;br /&gt;
*There is no support for generics in Go, although there are many discussions around it.&lt;br /&gt;
*Confusing Semantics Of Exported Identifiers&amp;lt;ref name = &amp;quot;Limitations2&amp;quot;&amp;gt;&lt;br /&gt;
[https://functionwhatwhat.com/go’s-type-system-is-an-embarrassment functionwhatwhat ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=87547</id>
		<title>CSC/ECE 517 Fall 2014/ch1a 10 hu</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=87547"/>
		<updated>2014-09-20T01:39:52Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /*  Go Programming Language */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==''' Go Programming Language''' ==&lt;br /&gt;
'''Go''', also commonly referred to as '''golang''', is a compiled, concurrent, garbage-collected, statically typed language developed at [http://en.wikipedia.org/wiki/Google Google]. It was developed by [http://en.wikipedia.org/wiki/Robert_Griesemer Robert Griesemer], [http://en.wikipedia.org/wiki/Rob_Pike Rob Pike] and [http://en.wikipedia.org/wiki/Ken_Thompson Ken Thompson] in 2007. It was announced in November 2009 and is currently being used in many production systems at Google. It is an open source project. The syntax is loosely derived from that of [http://en.wikipedia.org/wiki/C_(programming_language) C programming language], adding [http://en.wikipedia.org/wiki/Garbage_collection_(computer_science) Garbage collection], type safety, some dynamic-typing capabilities. Additional built-in types such as variable-length arrays and key-value maps, and a large standard library are also supported. Different operating systems like Linux, Microsoft Windows, Mac OS X are suported by [https://golang.org/cmd/gc Gc] compiler of Go.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
&lt;br /&gt;
Go programming started of as a research project by Robert Griesemer, Rob Pike and Ken Thompson. They felt that there was no new system focused programming language that has come up in the last decade till 2008, while there were other developments like increase in the size of libraries, dominance of networking , client server focus, multi-core CPUs.&amp;lt;ref name = &amp;quot;Background 1&amp;quot;&amp;gt;[https://www.youtube.com/watch?v=rKnDgT73v8s Go Language Introduction speech]&amp;lt;/ref&amp;gt; So they wanted to come up with a new systems focused programming language that would address the above issues.&amp;lt;ref name=&amp;quot;BG2&amp;quot;&amp;gt;[http://techcrunch.com/2009/11/10/google-go-language TechCrunch]&amp;lt;/ref&amp;gt; They started sketching the goals for a new language on the white board on September 21, 2007. Within a few days the goals had settled into a plan to do something and a fair idea of what it would be. Design continued part-time in parallel with unrelated work.&lt;br /&gt;
By January 2008, Ken had started work on a compiler with which to explore ideas; it generated C code as its output. By mid-year the language had become a full-time project and had settled enough to attempt a production compiler. In May 2008, [http://research.google.com/pubs/author37504.html Ian Taylor] independently started on a [http://en.wikipedia.org/wiki/GNU_Compiler_Collection GCC] front end for Go using the draft specification.  [http://russ.cox.usesthis.com/ Russ Cox] joined in late 2008 and helped move the language and libraries from prototype to reality.&lt;br /&gt;
Go became a public [http://en.wikipedia.org/wiki/Open_source open source project] on November 10, 2009. Many people from the community have contributed ideas, discussions, and code.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Compilers and Runtime support=&lt;br /&gt;
&lt;br /&gt;
There are two Go compiler implementations, [https://golang.org/cmd/gc Gc] (the 6g program and friends) and [http://blog.golang.org/gccgo-in-gcc-471 gccgo ]. Gc uses a different calling convention and linker. It can therefore only be linked with C programs using the same convention. Gccgo is a GCC front-end that can be linked with GCC-compiled C or C++ programs.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cgo program provides the mechanism for a “foreign function interface” to allow safe calling of C libraries from Go code. [http://en.wikipedia.org/wiki/SWIG SWIG] extends this capability to C++ libraries. &lt;br /&gt;
&lt;br /&gt;
Again due to bootstrapping issues, the run-time code is mostly in C (with a tiny bit of assembler) although Go is capable of implementing most of it now. Gccgo's run-time support uses glibc. Gc uses a custom library to keep the footprint under control; it is compiled with a version of the [http://plan9.bell-labs.com/sys/doc/compiler.html Plan 9 C compiler] that supports resizable stacks for goroutines. The gccgo compiler implements these on Linux only, using a technique called segmented stacks, supported by recent modifications to the gold linker.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find all resources needed to compile and run Go Language here http://go-lang.cat-v.org/&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
 &lt;br /&gt;
Programming today involves too much bookkeeping, repetition, and clerical work. As Dick Gabriel says, “Old programs read like quiet conversations between a well-spoken research worker and a well-studied mechanical colleague, not as a debate with a compiler. Who'd have guessed sophistication bought such noise?” The sophistication is worthwhile—no one wants to go back to the old languages—but can it be more quietly achieved?&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Go attempts to reduce the amount of typing in both senses of the word. Throughout its design, &lt;br /&gt;
*They have tried to reduce clutter and complexity. &lt;br /&gt;
*There are no forward declarations and no header files. everything is declared exactly once. &lt;br /&gt;
*Initialization is expressive, automatic, and easy to use. &lt;br /&gt;
*Syntax is clean and light on keywords. Stuttering (foo.Foo* myFoo = new(foo.Foo)) is reduced by simple type derivation using the := declare-and-initialize construct. &lt;br /&gt;
*And perhaps most radically, there is no type hierarchy. They don't have to announce their relationships.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
These simplifications allow Go to be expressive yet comprehensible without sacrificing, well, sophistication.&lt;br /&gt;
Another important principle is to keep the concepts orthogonal. Methods can be implemented for any type; structures represent data while interfaces represent abstraction; and so on. Orthogonality makes it easier to understand what happens when things combine.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Language Design&amp;lt;ref name = &amp;quot;GoLang Book&amp;quot;&amp;gt;[http://www.golang-book.com, GoLang Book]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 package main //line 1&lt;br /&gt;
&lt;br /&gt;
   import “fmt”  //line 2&lt;br /&gt;
&lt;br /&gt;
   func main() {  //line 3&lt;br /&gt;
&lt;br /&gt;
       fmt.Println(“Hello World”) //line 4&lt;br /&gt;
&lt;br /&gt;
   } //line 5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Line1 specifies package declaration. Package is used to organize and reuse code. Line 2 is used for including the package “fmt” which is used for formatting input and output. Line 3 to 5 defines the function main. main is the function which is called when a program is executed. Println function in fmt is used to display content to the console i.e in this example Hello World is displayed in the console on executing the program.&lt;br /&gt;
&lt;br /&gt;
==Code Conventions and Style==&lt;br /&gt;
&lt;br /&gt;
* Go fmt tool is used to automatically standardize indentation, spaces and surface-level code details. go vet and go link are perform checking automatically.&lt;br /&gt;
* Using tools and libraries provided in Go, there are standard approaches for API documentation(go doc), testing(go test), building(go build) and package management(go get).&lt;br /&gt;
* Syntax prevents any kind of cyclic dependencies.&lt;br /&gt;
* Unused variables and imports are not allowed.&lt;br /&gt;
* Elimination of functional programming constructs (such as map and try/finally in C++) ensure a concrete and explicit programming style.&lt;br /&gt;
&lt;br /&gt;
==Types==&lt;br /&gt;
&lt;br /&gt;
* Numbers are represented in Go as either Integers or Floating point numbers.&lt;br /&gt;
**Integers: Used to represent numbers without a decimal component. Different integers supported by Go are: uint8, uint16, uint32, uint64, int8, int16, int32, int64. Uint is used for unsigned integers and int for signed. 8,16, 32, 64 indicate the number of bits each type would use.&lt;br /&gt;
**Floating Point Integers: Used to support decimal components. Go supports float32 and float64 to represent floating point numbers and complex32 and complex64 to represent complex numbers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var x int32 =4&lt;br /&gt;
var y float32 = 4.5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* String: String litersals can be created using either double quotes(“Hello”) or back ticks(`Hello`). Strings have several operations associated them, for example one can find the length of the string or get a character at a specific index in a string.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
	fmt.Println(len(“Hello”)) // output: 5&lt;br /&gt;
	fmt.Println(“Hello”[1]) // output: 1&lt;br /&gt;
	fmt.Println(“Hello “+”Tom”) //output: Hello Tom&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Boolean: A 1 bit value is used to represent true or false.&lt;br /&gt;
&lt;br /&gt;
==Variables and Constants==&lt;br /&gt;
*Variabes in Go are indicated using the var keyword. Example: var x string=”hello” . They can also be shorthanded as x:=”hello” .&lt;br /&gt;
*The variable names should begin with a letter and can contain letters, digits or underscore character.&lt;br /&gt;
*The scope of the variable is the block in which it is defined and an attempt to access it outside the block would result in an error on running the program.&lt;br /&gt;
*Go provides support for constants (i.e. variables whose value can not be changed), using the const keyword. Example: const temp string = “Hello”&lt;br /&gt;
*In Go one can define multiple variables(or constants) using the following syntax:&lt;br /&gt;
    var(&lt;br /&gt;
         t1 =1&lt;br /&gt;
         t2=2&lt;br /&gt;
         t3=3&lt;br /&gt;
        t4=4&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Control Structures==&lt;br /&gt;
*For: It is used for repeating a list of statement(s) multiple times. The example below is used for calculating sum of numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    i := 1&lt;br /&gt;
    sum := 0&lt;br /&gt;
&lt;br /&gt;
    for i &amp;lt;= 10 {&lt;br /&gt;
        sum = sum + i&lt;br /&gt;
        i = i + 1&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    fmt.Println(“Sum:” + sum)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the example above i is a loop counter variable and is used to ensure that sum of numbers from 1 to 10 is computed. It indicates the number of times the statements inside the for loop is to be executed. The statement following the keyword for should evaluate to either true or false. If it is evaluated to true the body of for is executed, else we come out of the for loop.&lt;br /&gt;
&lt;br /&gt;
*If: Used to execute a block of statement(s) based on the evaluation of an expression to either true or false. It can also have an else associated with it.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    if i % 2 == 0 {&lt;br /&gt;
        fmt.Println(i + ” is divisble by 2”)&lt;br /&gt;
    } else {&lt;br /&gt;
        fmt.Println(i + “is not divisible by 2”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Switch: The value of the expression following switch is evaluated and is compared against the different cases. Based on the matching case, the block following that case is executed. Switch also has a default case in situations when none of the cases are matching.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    // if op ==1 then so a+b&lt;br /&gt;
    // if op == 2 then do a-b&lt;br /&gt;
    // if op == 3 then do a*b&lt;br /&gt;
    // if op ==4 then do a/b&lt;br /&gt;
    // default print, invalid operator&lt;br /&gt;
&lt;br /&gt;
    op:= 1&lt;br /&gt;
    a=6&lt;br /&gt;
    b=7&lt;br /&gt;
    switch(op) {&lt;br /&gt;
        case 1: fmt.Println(a+b)&lt;br /&gt;
        case 2: fmt.Println(a-b)&lt;br /&gt;
        case 3: fmt.Println(a*b)&lt;br /&gt;
        case 4: fmt.Println(a/b)&lt;br /&gt;
        default: fmt.Println(“Invalid Operator”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Arrays, Slices and Maps==&lt;br /&gt;
&lt;br /&gt;
*Arrays: Numbered sequence of elements starting with index zero and each of the elements having a fixed length. The example below illustrates various operations performed on arrays in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
    var x[10] int&lt;br /&gt;
    x[99]=100&lt;br /&gt;
    fmt.Println(x)  //[0 0 ….. 0 100]&lt;br /&gt;
    fmt.Println(len(x)) //100&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Slices: &lt;br /&gt;
** It is a segment of an array.&lt;br /&gt;
** They have a length and are indexable.&lt;br /&gt;
**In case of a slice the size does not have to specified in the square bracket.&lt;br /&gt;
**Slices support two in-build functions: copy and append.&lt;br /&gt;
**The program below illustrates the different ways to create slices and use of copy and append.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    arr := [10] int {1,2,3,4,5,6,7,8,9,10}&lt;br /&gt;
    x := make([]int,10) // creates a slice [1...10]&lt;br /&gt;
    y := make([]int,10,10) //creates a slice [1...10]&lt;br /&gt;
    z := arr[0:10] //creates a slice [1...10]&lt;br /&gt;
    s1 := []int{1,2,3,4,5}&lt;br /&gt;
    s2 := append(s1, 6, 7)&lt;br /&gt;
    fmt.Println(s1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(s2) // [1,2,3,4,5,6,7]&lt;br /&gt;
    p1 := [] int{1,2,3,4,5}&lt;br /&gt;
    p2 :=make([]int, 4)&lt;br /&gt;
    copy(p2,p1)&lt;br /&gt;
    fmt.Println(p1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(p2)// [1,2,3,4]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Maps:&lt;br /&gt;
**A map is an unordered collection of key value pairs.&lt;br /&gt;
**Syntax: var x map[int] string , where int is the type of the key and string is the type of the value.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
    x := make(map[int]string)&lt;br /&gt;
    x[1] = one&lt;br /&gt;
    x[2] = two&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
&lt;br /&gt;
*In Go functions can take multiple inputs and return multiple outputs.&lt;br /&gt;
*Go supports a special kind of function called variadic function.&lt;br /&gt;
*Closure is the means by which functions can be created inside other function in Go.&lt;br /&gt;
*Go supports recursive functions.&lt;br /&gt;
*The example below the different types of function in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    display(“Hello World”)&lt;br /&gt;
    sum :=calculateSum(10,20)&lt;br /&gt;
    v1,v2=multipleValues()&lt;br /&gt;
    p=product(5,10,20)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function without return type&lt;br /&gt;
func display( s string) {&lt;br /&gt;
    fmt.Println(s)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns a single value&lt;br /&gt;
func calculateSum(a int, b int) int {&lt;br /&gt;
    c: = a + b&lt;br /&gt;
    return c&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns multiple values&lt;br /&gt;
func multipleValues(int, int) {&lt;br /&gt;
    return 1, 2&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Variadic function&lt;br /&gt;
func product(args ...int) int {&lt;br /&gt;
    p := 1&lt;br /&gt;
   for _, i := range args {&lt;br /&gt;
        p *= i&lt;br /&gt;
   }&lt;br /&gt;
   return p&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pointers==&lt;br /&gt;
It is used to reference a location in the memory where the value is stored rather than containing the value itself. Basic pointer operations in Go are illustrated in the example below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
//Different syntax for pointers&lt;br /&gt;
    &lt;br /&gt;
     ptr1 *int&lt;br /&gt;
     num :=10&lt;br /&gt;
     ptr1 = &amp;amp;num&lt;br /&gt;
     ptr2 := new(int)&lt;br /&gt;
     ptr2=&amp;amp;num&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Concurrency==&lt;br /&gt;
* Go ensures concurrency which allows sharing of state using communication mechanisms.&lt;br /&gt;
* Go provides support for multithreading and CPU parallelization.&lt;br /&gt;
* Go supports asynchrony i.e. allows operations like database and network I/O which are slow operations to occur in parallel along with other operations.&lt;br /&gt;
* A new lightweight process is created using go fund()&lt;br /&gt;
* Channel types are used for providing type safe and synchronized channels between different go routines.&lt;br /&gt;
&lt;br /&gt;
=Users of Go=&lt;br /&gt;
Apart from Google, which uses Go programming for some of its development, companies like [http://en.wikipedia.org/wiki/Dropbox_(service) Dropbox], [http://en.wikipedia.org/wiki/CloudFlare CloudFlare], [http://en.wikipedia.org/wiki/SoundCloud SoundCloud], The BBC, Novartis, Cloud Foundry also use Go programming.  &lt;br /&gt;
Dropbox server (running in the cloud) and desktop client software were primarily written in [http://en.wikipedia.org/wiki/Python_(programming_language) Python]. From mid-2013 Dropbox began migrating its backend infrastructure to Go.&lt;br /&gt;
Some of the open-source applications that are using Go programming are Docker, Flynn, PaaS, Juju, nsq, Doozer e.t.c .&amp;lt;ref name = &amp;quot;GoWIKI&amp;quot;&amp;gt;[http://en.wikipedia.org/wiki/Go_(programming_language), Wikipedia]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advantages=&lt;br /&gt;
 &lt;br /&gt;
*'''C Level Performance'''. golang is within a close margin of the performance level of C code (which is itself an extremely high performance language). It is certainly closer to the performance of native languages than other enterprise level languages such as Java, Scala, Erlang etc.&lt;br /&gt;
 &lt;br /&gt;
*'''Fast Compilation''' is one of the key advantages of Go language. The Golang compiler was designed to compile programs very quickly. Extremely large programs with massively high LOC counts compile seemingly instantly - after all, Golang was designed by Google to solve Google problems, and Google has big problems! At Google, code and CPU cores are both measured in the millions. Go provides a model for software construction that makes dependency analysis easy and avoids much of the overhead of C-style include files and libraries.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reduced compile time is a key improvement in the Go language&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      If A.go depends on B.go depends on C.go :&lt;br /&gt;
         Compile C.go, B.go then A.go normally (other languages)&lt;br /&gt;
         To compile A.go, compiler reads B.o not C.o (go)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At a large scale this should help in hugely speeding up&lt;br /&gt;
&lt;br /&gt;
Other advantages are      &lt;br /&gt;
* '''Concurrency Supported At Language Level'''. Concurrency is the ability to execute multiple computations simultaneously. In today's modern multicore and high-load computing environment, concurrency is a critical language feature, and one in which languages such as Java struggle immensely.&lt;br /&gt;
* By its design, Go proposes an approach for the construction of system software on '''multicore machines'''.&lt;br /&gt;
* Google have summed things up nicely with their motto: '''Don't communicate by sharing memory, share memory by communicating'''.Channels allow you to pass references to data structures between goroutines. If you consider this as passing around ownership of the data (the ability to read and write it), they become a powerful and expressive synchronization mechanism.  &lt;br /&gt;
* '''Go's type system has no hierarchy''', so no time is spent defining the relationships between types. Also, although Go has static types, the language attempts to make types feel lighter weight than in typical Object Oriented languages.&lt;br /&gt;
* '''Garbage Collection is much better'''. In C and C++, programmers spend a lot of time and energy on allocating and freeing memory. The designers of Go wanted to remove that complication, and ensure Go programmers could concentrate on more productive tasks. As such, they implemented garbage collection. As a developer, this is a very good thing. Sure, garbage collection comes with its own set of issues, but those are dealt with by the language implementer while the programmer is free to reap the other many benefits of Go.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
*Go is still an experimental language subject to change.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;&amp;gt;[http://stackoverflow.com/questions/2198529/what-are-the-advantages-and-disadvantages-of-go-programming-language stackoverflow]&amp;lt;/ref&amp;gt;&lt;br /&gt;
*Go's not very usable on Windows yet.&lt;br /&gt;
*The packages distributed with Go are pretty useful, but there are still some libraries you'll miss. Most notably a UI toolkit.&lt;br /&gt;
*There is no support for generics in Go, although there are many discussions around it.&lt;br /&gt;
*Confusing Semantics Of Exported Identifiers&amp;lt;ref name = &amp;quot;Limitations2&amp;quot;&amp;gt;&lt;br /&gt;
[https://functionwhatwhat.com/go’s-type-system-is-an-embarrassment functionwhatwhat ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=87532</id>
		<title>CSC/ECE 517 Fall 2014/ch1a 10 hu</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=87532"/>
		<updated>2014-09-20T01:35:46Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==''' Go Programming Language''' ==&lt;br /&gt;
'''Go''', also commonly referred to as '''golang''', is a compiled, concurrent, garbage-collected, statically typed language developed at [http://en.wikipedia.org/wiki/Google Google]. It was developed by [http://en.wikipedia.org/wiki/Robert_Griesemer Robert Griesemer], [http://en.wikipedia.org/wiki/Rob_Pike Rob Pike] and [http://en.wikipedia.org/wiki/Ken_Thompson Ken Thompson] in 2007. It was announced in November 2009 and is currently being used in many production systems at Google. It is an open source project. The syntax is loosely derived from that of [http://en.wikipedia.org/wiki/C_(programming_language) C programming language], adding [http://en.wikipedia.org/wiki/Garbage_collection_(computer_science) Garbage collection], type safety, some dynamic-typing capabilities. Additional built-in types such as variable-length arrays and key-value maps, and a large standard library are also supported. Different operating systems like Linux, Microsoft Windows, Mac OS X are suported by gc compiler of Go.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
&lt;br /&gt;
Go programming started of as a research project by Robert Griesemer, Rob Pike and Ken Thompson. They felt that there was no new system focused programming language that has come up in the last decade till 2008, while there were other developments like increase in the size of libraries, dominance of networking , client server focus, multi-core CPUs.&amp;lt;ref name = &amp;quot;Background 1&amp;quot;&amp;gt;[https://www.youtube.com/watch?v=rKnDgT73v8s Go Language Introduction speech]&amp;lt;/ref&amp;gt; So they wanted to come up with a new systems focused programming language that would address the above issues.&amp;lt;ref name=&amp;quot;BG2&amp;quot;&amp;gt;[http://techcrunch.com/2009/11/10/google-go-language TechCrunch]&amp;lt;/ref&amp;gt; They started sketching the goals for a new language on the white board on September 21, 2007. Within a few days the goals had settled into a plan to do something and a fair idea of what it would be. Design continued part-time in parallel with unrelated work.&lt;br /&gt;
By January 2008, Ken had started work on a compiler with which to explore ideas; it generated C code as its output. By mid-year the language had become a full-time project and had settled enough to attempt a production compiler. In May 2008, [http://research.google.com/pubs/author37504.html Ian Taylor] independently started on a [http://en.wikipedia.org/wiki/GNU_Compiler_Collection GCC] front end for Go using the draft specification.  [http://russ.cox.usesthis.com/ Russ Cox] joined in late 2008 and helped move the language and libraries from prototype to reality.&lt;br /&gt;
Go became a public [http://en.wikipedia.org/wiki/Open_source open source project] on November 10, 2009. Many people from the community have contributed ideas, discussions, and code.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Compilers and Runtime support=&lt;br /&gt;
&lt;br /&gt;
There are two Go compiler implementations, [https://golang.org/cmd/gc Gc] (the 6g program and friends) and [http://blog.golang.org/gccgo-in-gcc-471 gccgo ]. Gc uses a different calling convention and linker. It can therefore only be linked with C programs using the same convention. Gccgo is a GCC front-end that can be linked with GCC-compiled C or C++ programs.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cgo program provides the mechanism for a “foreign function interface” to allow safe calling of C libraries from Go code. [http://en.wikipedia.org/wiki/SWIG SWIG] extends this capability to C++ libraries. &lt;br /&gt;
&lt;br /&gt;
Again due to bootstrapping issues, the run-time code is mostly in C (with a tiny bit of assembler) although Go is capable of implementing most of it now. Gccgo's run-time support uses glibc. Gc uses a custom library to keep the footprint under control; it is compiled with a version of the [http://plan9.bell-labs.com/sys/doc/compiler.html Plan 9 C compiler] that supports resizable stacks for goroutines. The gccgo compiler implements these on Linux only, using a technique called segmented stacks, supported by recent modifications to the gold linker.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find all resources needed to compile and run Go Language here http://go-lang.cat-v.org/&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
 &lt;br /&gt;
Programming today involves too much bookkeeping, repetition, and clerical work. As Dick Gabriel says, “Old programs read like quiet conversations between a well-spoken research worker and a well-studied mechanical colleague, not as a debate with a compiler. Who'd have guessed sophistication bought such noise?” The sophistication is worthwhile—no one wants to go back to the old languages—but can it be more quietly achieved?&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Go attempts to reduce the amount of typing in both senses of the word. Throughout its design, &lt;br /&gt;
*They have tried to reduce clutter and complexity. &lt;br /&gt;
*There are no forward declarations and no header files. everything is declared exactly once. &lt;br /&gt;
*Initialization is expressive, automatic, and easy to use. &lt;br /&gt;
*Syntax is clean and light on keywords. Stuttering (foo.Foo* myFoo = new(foo.Foo)) is reduced by simple type derivation using the := declare-and-initialize construct. &lt;br /&gt;
*And perhaps most radically, there is no type hierarchy. They don't have to announce their relationships.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
These simplifications allow Go to be expressive yet comprehensible without sacrificing, well, sophistication.&lt;br /&gt;
Another important principle is to keep the concepts orthogonal. Methods can be implemented for any type; structures represent data while interfaces represent abstraction; and so on. Orthogonality makes it easier to understand what happens when things combine.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Language Design&amp;lt;ref name = &amp;quot;GoLang Book&amp;quot;&amp;gt;[http://www.golang-book.com, GoLang Book]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 package main //line 1&lt;br /&gt;
&lt;br /&gt;
   import “fmt”  //line 2&lt;br /&gt;
&lt;br /&gt;
   func main() {  //line 3&lt;br /&gt;
&lt;br /&gt;
       fmt.Println(“Hello World”) //line 4&lt;br /&gt;
&lt;br /&gt;
   } //line 5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Line1 specifies package declaration. Package is used to organize and reuse code. Line 2 is used for including the package “fmt” which is used for formatting input and output. Line 3 to 5 defines the function main. main is the function which is called when a program is executed. Println function in fmt is used to display content to the console i.e in this example Hello World is displayed in the console on executing the program.&lt;br /&gt;
&lt;br /&gt;
==Code Conventions and Style==&lt;br /&gt;
&lt;br /&gt;
* Go fmt tool is used to automatically standardize indentation, spaces and surface-level code details. go vet and go link are perform checking automatically.&lt;br /&gt;
* Using tools and libraries provided in Go, there are standard approaches for API documentation(go doc), testing(go test), building(go build) and package management(go get).&lt;br /&gt;
* Syntax prevents any kind of cyclic dependencies.&lt;br /&gt;
* Unused variables and imports are not allowed.&lt;br /&gt;
* Elimination of functional programming constructs (such as map and try/finally in C++) ensure a concrete and explicit programming style.&lt;br /&gt;
&lt;br /&gt;
==Types==&lt;br /&gt;
&lt;br /&gt;
* Numbers are represented in Go as either Integers or Floating point numbers.&lt;br /&gt;
**Integers: Used to represent numbers without a decimal component. Different integers supported by Go are: uint8, uint16, uint32, uint64, int8, int16, int32, int64. Uint is used for unsigned integers and int for signed. 8,16, 32, 64 indicate the number of bits each type would use.&lt;br /&gt;
**Floating Point Integers: Used to support decimal components. Go supports float32 and float64 to represent floating point numbers and complex32 and complex64 to represent complex numbers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var x int32 =4&lt;br /&gt;
var y float32 = 4.5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* String: String litersals can be created using either double quotes(“Hello”) or back ticks(`Hello`). Strings have several operations associated them, for example one can find the length of the string or get a character at a specific index in a string.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
	fmt.Println(len(“Hello”)) // output: 5&lt;br /&gt;
	fmt.Println(“Hello”[1]) // output: 1&lt;br /&gt;
	fmt.Println(“Hello “+”Tom”) //output: Hello Tom&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Boolean: A 1 bit value is used to represent true or false.&lt;br /&gt;
&lt;br /&gt;
==Variables and Constants==&lt;br /&gt;
*Variabes in Go are indicated using the var keyword. Example: var x string=”hello” . They can also be shorthanded as x:=”hello” .&lt;br /&gt;
*The variable names should begin with a letter and can contain letters, digits or underscore character.&lt;br /&gt;
*The scope of the variable is the block in which it is defined and an attempt to access it outside the block would result in an error on running the program.&lt;br /&gt;
*Go provides support for constants (i.e. variables whose value can not be changed), using the const keyword. Example: const temp string = “Hello”&lt;br /&gt;
*In Go one can define multiple variables(or constants) using the following syntax:&lt;br /&gt;
    var(&lt;br /&gt;
         t1 =1&lt;br /&gt;
         t2=2&lt;br /&gt;
         t3=3&lt;br /&gt;
        t4=4&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Control Structures==&lt;br /&gt;
*For: It is used for repeating a list of statement(s) multiple times. The example below is used for calculating sum of numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    i := 1&lt;br /&gt;
    sum := 0&lt;br /&gt;
&lt;br /&gt;
    for i &amp;lt;= 10 {&lt;br /&gt;
        sum = sum + i&lt;br /&gt;
        i = i + 1&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    fmt.Println(“Sum:” + sum)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the example above i is a loop counter variable and is used to ensure that sum of numbers from 1 to 10 is computed. It indicates the number of times the statements inside the for loop is to be executed. The statement following the keyword for should evaluate to either true or false. If it is evaluated to true the body of for is executed, else we come out of the for loop.&lt;br /&gt;
&lt;br /&gt;
*If: Used to execute a block of statement(s) based on the evaluation of an expression to either true or false. It can also have an else associated with it.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    if i % 2 == 0 {&lt;br /&gt;
        fmt.Println(i + ” is divisble by 2”)&lt;br /&gt;
    } else {&lt;br /&gt;
        fmt.Println(i + “is not divisible by 2”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Switch: The value of the expression following switch is evaluated and is compared against the different cases. Based on the matching case, the block following that case is executed. Switch also has a default case in situations when none of the cases are matching.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    // if op ==1 then so a+b&lt;br /&gt;
    // if op == 2 then do a-b&lt;br /&gt;
    // if op == 3 then do a*b&lt;br /&gt;
    // if op ==4 then do a/b&lt;br /&gt;
    // default print, invalid operator&lt;br /&gt;
&lt;br /&gt;
    op:= 1&lt;br /&gt;
    a=6&lt;br /&gt;
    b=7&lt;br /&gt;
    switch(op) {&lt;br /&gt;
        case 1: fmt.Println(a+b)&lt;br /&gt;
        case 2: fmt.Println(a-b)&lt;br /&gt;
        case 3: fmt.Println(a*b)&lt;br /&gt;
        case 4: fmt.Println(a/b)&lt;br /&gt;
        default: fmt.Println(“Invalid Operator”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Arrays, Slices and Maps==&lt;br /&gt;
&lt;br /&gt;
*Arrays: Numbered sequence of elements starting with index zero and each of the elements having a fixed length. The example below illustrates various operations performed on arrays in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
    var x[10] int&lt;br /&gt;
    x[99]=100&lt;br /&gt;
    fmt.Println(x)  //[0 0 ….. 0 100]&lt;br /&gt;
    fmt.Println(len(x)) //100&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Slices: &lt;br /&gt;
** It is a segment of an array.&lt;br /&gt;
** They have a length and are indexable.&lt;br /&gt;
**In case of a slice the size does not have to specified in the square bracket.&lt;br /&gt;
**Slices support two in-build functions: copy and append.&lt;br /&gt;
**The program below illustrates the different ways to create slices and use of copy and append.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    arr := [10] int {1,2,3,4,5,6,7,8,9,10}&lt;br /&gt;
    x := make([]int,10) // creates a slice [1...10]&lt;br /&gt;
    y := make([]int,10,10) //creates a slice [1...10]&lt;br /&gt;
    z := arr[0:10] //creates a slice [1...10]&lt;br /&gt;
    s1 := []int{1,2,3,4,5}&lt;br /&gt;
    s2 := append(s1, 6, 7)&lt;br /&gt;
    fmt.Println(s1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(s2) // [1,2,3,4,5,6,7]&lt;br /&gt;
    p1 := [] int{1,2,3,4,5}&lt;br /&gt;
    p2 :=make([]int, 4)&lt;br /&gt;
    copy(p2,p1)&lt;br /&gt;
    fmt.Println(p1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(p2)// [1,2,3,4]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Maps:&lt;br /&gt;
**A map is an unordered collection of key value pairs.&lt;br /&gt;
**Syntax: var x map[int] string , where int is the type of the key and string is the type of the value.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
    x := make(map[int]string)&lt;br /&gt;
    x[1] = one&lt;br /&gt;
    x[2] = two&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
&lt;br /&gt;
*In Go functions can take multiple inputs and return multiple outputs.&lt;br /&gt;
*Go supports a special kind of function called variadic function.&lt;br /&gt;
*Closure is the means by which functions can be created inside other function in Go.&lt;br /&gt;
*Go supports recursive functions.&lt;br /&gt;
*The example below the different types of function in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    display(“Hello World”)&lt;br /&gt;
    sum :=calculateSum(10,20)&lt;br /&gt;
    v1,v2=multipleValues()&lt;br /&gt;
    p=product(5,10,20)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function without return type&lt;br /&gt;
func display( s string) {&lt;br /&gt;
    fmt.Println(s)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns a single value&lt;br /&gt;
func calculateSum(a int, b int) int {&lt;br /&gt;
    c: = a + b&lt;br /&gt;
    return c&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns multiple values&lt;br /&gt;
func multipleValues(int, int) {&lt;br /&gt;
    return 1, 2&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Variadic function&lt;br /&gt;
func product(args ...int) int {&lt;br /&gt;
    p := 1&lt;br /&gt;
   for _, i := range args {&lt;br /&gt;
        p *= i&lt;br /&gt;
   }&lt;br /&gt;
   return p&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pointers==&lt;br /&gt;
It is used to reference a location in the memory where the value is stored rather than containing the value itself. Basic pointer operations in Go are illustrated in the example below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
//Different syntax for pointers&lt;br /&gt;
    &lt;br /&gt;
     ptr1 *int&lt;br /&gt;
     num :=10&lt;br /&gt;
     ptr1 = &amp;amp;num&lt;br /&gt;
     ptr2 := new(int)&lt;br /&gt;
     ptr2=&amp;amp;num&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Concurrency==&lt;br /&gt;
* Go ensures concurrency which allows sharing of state using communication mechanisms.&lt;br /&gt;
* Go provides support for multithreading and CPU parallelization.&lt;br /&gt;
* Go supports asynchrony i.e. allows operations like database and network I/O which are slow operations to occur in parallel along with other operations.&lt;br /&gt;
* A new lightweight process is created using go fund()&lt;br /&gt;
* Channel types are used for providing type safe and synchronized channels between different go routines.&lt;br /&gt;
&lt;br /&gt;
=Users of Go=&lt;br /&gt;
Apart from Google, which uses Go programming for some of its development, companies like [http://en.wikipedia.org/wiki/Dropbox_(service) Dropbox], [http://en.wikipedia.org/wiki/CloudFlare CloudFlare], [http://en.wikipedia.org/wiki/SoundCloud SoundCloud], The BBC, Novartis, Cloud Foundry also use Go programming.  &lt;br /&gt;
Dropbox server (running in the cloud) and desktop client software were primarily written in [http://en.wikipedia.org/wiki/Python_(programming_language) Python]. From mid-2013 Dropbox began migrating its backend infrastructure to Go.&lt;br /&gt;
Some of the open-source applications that are using Go programming are Docker, Flynn, PaaS, Juju, nsq, Doozer e.t.c .&amp;lt;ref name = &amp;quot;GoWIKI&amp;quot;&amp;gt;[http://en.wikipedia.org/wiki/Go_(programming_language), Wikipedia]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advantages=&lt;br /&gt;
 &lt;br /&gt;
*'''C Level Performance'''. golang is within a close margin of the performance level of C code (which is itself an extremely high performance language). It is certainly closer to the performance of native languages than other enterprise level languages such as Java, Scala, Erlang etc.&lt;br /&gt;
 &lt;br /&gt;
*'''Fast Compilation''' is one of the key advantages of Go language. The Golang compiler was designed to compile programs very quickly. Extremely large programs with massively high LOC counts compile seemingly instantly - after all, Golang was designed by Google to solve Google problems, and Google has big problems! At Google, code and CPU cores are both measured in the millions. Go provides a model for software construction that makes dependency analysis easy and avoids much of the overhead of C-style include files and libraries.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reduced compile time is a key improvement in the Go language&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      If A.go depends on B.go depends on C.go :&lt;br /&gt;
         Compile C.go, B.go then A.go normally (other languages)&lt;br /&gt;
         To compile A.go, compiler reads B.o not C.o (go)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At a large scale this should help in hugely speeding up&lt;br /&gt;
&lt;br /&gt;
Other advantages are      &lt;br /&gt;
* '''Concurrency Supported At Language Level'''. Concurrency is the ability to execute multiple computations simultaneously. In today's modern multicore and high-load computing environment, concurrency is a critical language feature, and one in which languages such as Java struggle immensely.&lt;br /&gt;
* By its design, Go proposes an approach for the construction of system software on '''multicore machines'''.&lt;br /&gt;
* Google have summed things up nicely with their motto: '''Don't communicate by sharing memory, share memory by communicating'''.Channels allow you to pass references to data structures between goroutines. If you consider this as passing around ownership of the data (the ability to read and write it), they become a powerful and expressive synchronization mechanism.  &lt;br /&gt;
* '''Go's type system has no hierarchy''', so no time is spent defining the relationships between types. Also, although Go has static types, the language attempts to make types feel lighter weight than in typical Object Oriented languages.&lt;br /&gt;
* '''Garbage Collection is much better'''. In C and C++, programmers spend a lot of time and energy on allocating and freeing memory. The designers of Go wanted to remove that complication, and ensure Go programmers could concentrate on more productive tasks. As such, they implemented garbage collection. As a developer, this is a very good thing. Sure, garbage collection comes with its own set of issues, but those are dealt with by the language implementer while the programmer is free to reap the other many benefits of Go.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
*Go is still an experimental language subject to change.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;&amp;gt;[http://stackoverflow.com/questions/2198529/what-are-the-advantages-and-disadvantages-of-go-programming-language stackoverflow]&amp;lt;/ref&amp;gt;&lt;br /&gt;
*Go's not very usable on Windows yet.&lt;br /&gt;
*The packages distributed with Go are pretty useful, but there are still some libraries you'll miss. Most notably a UI toolkit.&lt;br /&gt;
*There is no support for generics in Go, although there are many discussions around it.&lt;br /&gt;
*Confusing Semantics Of Exported Identifiers&amp;lt;ref name = &amp;quot;Limitations2&amp;quot;&amp;gt;&lt;br /&gt;
[https://functionwhatwhat.com/go’s-type-system-is-an-embarrassment functionwhatwhat ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=87525</id>
		<title>CSC/ECE 517 Fall 2014/ch1a 10 hu</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=87525"/>
		<updated>2014-09-20T01:32:16Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==''' Go Programming Language''' ==&lt;br /&gt;
&lt;br /&gt;
'''Go''', also commonly referred to as '''golang''', is a compiled, concurrent, garbage-collected, statically typed language developed at [http://en.wikipedia.org/wiki/Google Google]. It was developed by [http://en.wikipedia.org/wiki/Robert_Griesemer Robert Griesemer], [http://en.wikipedia.org/wiki/Rob_Pike Rob Pike] and [http://en.wikipedia.org/wiki/Ken_Thompson Ken Thompson] in 2007. It was announced in November 2009 and is currently being used in many production systems at Google. It is an open source project. The syntax is loosely derived from that of [http://en.wikipedia.org/wiki/C_(programming_language) C programming language], adding [http://en.wikipedia.org/wiki/Garbage_collection_(computer_science) Garbage collection], type safety, some dynamic-typing capabilities. Additional built-in types such as variable-length arrays and key-value maps, and a large standard library are also supported. Different operating systems like Linux, Microsoft Windows, Mac OS X are suported by gc compiler of Go.&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
&lt;br /&gt;
Go programming started of as a research project by Robert Griesemer, Rob Pike and Ken Thompson. They felt that there was no new system focused programming language that has come up in the last decade till 2008, while there were other developments like increase in the size of libraries, dominance of networking , client server focus, multi-core CPUs.&amp;lt;ref name = &amp;quot;Background 1&amp;quot;&amp;gt;[https://www.youtube.com/watch?v=rKnDgT73v8s Go Language Introduction speech]&amp;lt;/ref&amp;gt; So they wanted to come up with a new systems focused programming language that would address the above issues.&amp;lt;ref name=&amp;quot;BG2&amp;quot;&amp;gt;[http://techcrunch.com/2009/11/10/google-go-language TechCrunch]&amp;lt;/ref&amp;gt; They started sketching the goals for a new language on the white board on September 21, 2007. Within a few days the goals had settled into a plan to do something and a fair idea of what it would be. Design continued part-time in parallel with unrelated work.&lt;br /&gt;
By January 2008, Ken had started work on a compiler with which to explore ideas; it generated C code as its output. By mid-year the language had become a full-time project and had settled enough to attempt a production compiler. In May 2008, [http://research.google.com/pubs/author37504.html Ian Taylor] independently started on a [http://en.wikipedia.org/wiki/GNU_Compiler_Collection GCC] front end for Go using the draft specification.  [http://russ.cox.usesthis.com/ Russ Cox] joined in late 2008 and helped move the language and libraries from prototype to reality.&lt;br /&gt;
Go became a public [http://en.wikipedia.org/wiki/Open_source open source project] on November 10, 2009. Many people from the community have contributed ideas, discussions, and code.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Compilers and Runtime support=&lt;br /&gt;
&lt;br /&gt;
There are two Go compiler implementations, [https://golang.org/cmd/gc Gc] (the 6g program and friends) and [http://blog.golang.org/gccgo-in-gcc-471 gccgo ]. Gc uses a different calling convention and linker. It can therefore only be linked with C programs using the same convention. Gccgo is a GCC front-end that can be linked with GCC-compiled C or C++ programs.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cgo program provides the mechanism for a “foreign function interface” to allow safe calling of C libraries from Go code. [http://en.wikipedia.org/wiki/SWIG SWIG] extends this capability to C++ libraries. &lt;br /&gt;
&lt;br /&gt;
Again due to bootstrapping issues, the run-time code is mostly in C (with a tiny bit of assembler) although Go is capable of implementing most of it now. Gccgo's run-time support uses glibc. Gc uses a custom library to keep the footprint under control; it is compiled with a version of the [http://plan9.bell-labs.com/sys/doc/compiler.html Plan 9 C compiler] that supports resizable stacks for goroutines. The gccgo compiler implements these on Linux only, using a technique called segmented stacks, supported by recent modifications to the gold linker.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find all resources needed to compile and run Go Language here http://go-lang.cat-v.org/&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
 &lt;br /&gt;
Programming today involves too much bookkeeping, repetition, and clerical work. As Dick Gabriel says, “Old programs read like quiet conversations between a well-spoken research worker and a well-studied mechanical colleague, not as a debate with a compiler. Who'd have guessed sophistication bought such noise?” The sophistication is worthwhile—no one wants to go back to the old languages—but can it be more quietly achieved?&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Go attempts to reduce the amount of typing in both senses of the word. Throughout its design, &lt;br /&gt;
*They have tried to reduce clutter and complexity. &lt;br /&gt;
*There are no forward declarations and no header files. everything is declared exactly once. &lt;br /&gt;
*Initialization is expressive, automatic, and easy to use. &lt;br /&gt;
*Syntax is clean and light on keywords. Stuttering (foo.Foo* myFoo = new(foo.Foo)) is reduced by simple type derivation using the := declare-and-initialize construct. &lt;br /&gt;
*And perhaps most radically, there is no type hierarchy. They don't have to announce their relationships.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
These simplifications allow Go to be expressive yet comprehensible without sacrificing, well, sophistication.&lt;br /&gt;
Another important principle is to keep the concepts orthogonal. Methods can be implemented for any type; structures represent data while interfaces represent abstraction; and so on. Orthogonality makes it easier to understand what happens when things combine.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Language Design&amp;lt;ref name = &amp;quot;GoLang Book&amp;quot;&amp;gt;[http://www.golang-book.com, GoLang Book]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 package main //line 1&lt;br /&gt;
&lt;br /&gt;
   import “fmt”  //line 2&lt;br /&gt;
&lt;br /&gt;
   func main() {  //line 3&lt;br /&gt;
&lt;br /&gt;
       fmt.Println(“Hello World”) //line 4&lt;br /&gt;
&lt;br /&gt;
   } //line 5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Line1 specifies package declaration. Package is used to organize and reuse code. Line 2 is used for including the package “fmt” which is used for formatting input and output. Line 3 to 5 defines the function main. main is the function which is called when a program is executed. Println function in fmt is used to display content to the console i.e in this example Hello World is displayed in the console on executing the program.&lt;br /&gt;
&lt;br /&gt;
==Code Conventions and Style==&lt;br /&gt;
&lt;br /&gt;
* Go fmt tool is used to automatically standardize indentation, spaces and surface-level code details. go vet and go link are perform checking automatically.&lt;br /&gt;
* Using tools and libraries provided in Go, there are standard approaches for API documentation(go doc), testing(go test), building(go build) and package management(go get).&lt;br /&gt;
* Syntax prevents any kind of cyclic dependencies.&lt;br /&gt;
* Unused variables and imports are not allowed.&lt;br /&gt;
* Elimination of functional programming constructs (such as map and try/finally in C++) ensure a concrete and explicit programming style.&lt;br /&gt;
&lt;br /&gt;
==Types==&lt;br /&gt;
&lt;br /&gt;
* Numbers are represented in Go as either Integers or Floating point numbers.&lt;br /&gt;
**Integers: Used to represent numbers without a decimal component. Different integers supported by Go are: uint8, uint16, uint32, uint64, int8, int16, int32, int64. Uint is used for unsigned integers and int for signed. 8,16, 32, 64 indicate the number of bits each type would use.&lt;br /&gt;
**Floating Point Integers: Used to support decimal components. Go supports float32 and float64 to represent floating point numbers and complex32 and complex64 to represent complex numbers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var x int32 =4&lt;br /&gt;
var y float32 = 4.5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* String: String litersals can be created using either double quotes(“Hello”) or back ticks(`Hello`). Strings have several operations associated them, for example one can find the length of the string or get a character at a specific index in a string.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
	fmt.Println(len(“Hello”)) // output: 5&lt;br /&gt;
	fmt.Println(“Hello”[1]) // output: 1&lt;br /&gt;
	fmt.Println(“Hello “+”Tom”) //output: Hello Tom&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Boolean: A 1 bit value is used to represent true or false.&lt;br /&gt;
&lt;br /&gt;
==Variables and Constants==&lt;br /&gt;
*Variabes in Go are indicated using the var keyword. Example: var x string=”hello” . They can also be shorthanded as x:=”hello” .&lt;br /&gt;
*The variable names should begin with a letter and can contain letters, digits or underscore character.&lt;br /&gt;
*The scope of the variable is the block in which it is defined and an attempt to access it outside the block would result in an error on running the program.&lt;br /&gt;
*Go provides support for constants (i.e. variables whose value can not be changed), using the const keyword. Example: const temp string = “Hello”&lt;br /&gt;
*In Go one can define multiple variables(or constants) using the following syntax:&lt;br /&gt;
    var(&lt;br /&gt;
         t1 =1&lt;br /&gt;
         t2=2&lt;br /&gt;
         t3=3&lt;br /&gt;
        t4=4&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Control Structures==&lt;br /&gt;
*For: It is used for repeating a list of statement(s) multiple times. The example below is used for calculating sum of numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    i := 1&lt;br /&gt;
    sum := 0&lt;br /&gt;
&lt;br /&gt;
    for i &amp;lt;= 10 {&lt;br /&gt;
        sum = sum + i&lt;br /&gt;
        i = i + 1&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    fmt.Println(“Sum:” + sum)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the example above i is a loop counter variable and is used to ensure that sum of numbers from 1 to 10 is computed. It indicates the number of times the statements inside the for loop is to be executed. The statement following the keyword for should evaluate to either true or false. If it is evaluated to true the body of for is executed, else we come out of the for loop.&lt;br /&gt;
&lt;br /&gt;
*If: Used to execute a block of statement(s) based on the evaluation of an expression to either true or false. It can also have an else associated with it.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    if i % 2 == 0 {&lt;br /&gt;
        fmt.Println(i + ” is divisble by 2”)&lt;br /&gt;
    } else {&lt;br /&gt;
        fmt.Println(i + “is not divisible by 2”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Switch: The value of the expression following switch is evaluated and is compared against the different cases. Based on the matching case, the block following that case is executed. Switch also has a default case in situations when none of the cases are matching.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    // if op ==1 then so a+b&lt;br /&gt;
    // if op == 2 then do a-b&lt;br /&gt;
    // if op == 3 then do a*b&lt;br /&gt;
    // if op ==4 then do a/b&lt;br /&gt;
    // default print, invalid operator&lt;br /&gt;
&lt;br /&gt;
    op:= 1&lt;br /&gt;
    a=6&lt;br /&gt;
    b=7&lt;br /&gt;
    switch(op) {&lt;br /&gt;
        case 1: fmt.Println(a+b)&lt;br /&gt;
        case 2: fmt.Println(a-b)&lt;br /&gt;
        case 3: fmt.Println(a*b)&lt;br /&gt;
        case 4: fmt.Println(a/b)&lt;br /&gt;
        default: fmt.Println(“Invalid Operator”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Arrays, Slices and Maps==&lt;br /&gt;
&lt;br /&gt;
*Arrays: Numbered sequence of elements starting with index zero and each of the elements having a fixed length. The example below illustrates various operations performed on arrays in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
    var x[10] int&lt;br /&gt;
    x[99]=100&lt;br /&gt;
    fmt.Println(x)  //[0 0 ….. 0 100]&lt;br /&gt;
    fmt.Println(len(x)) //100&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Slices: &lt;br /&gt;
** It is a segment of an array.&lt;br /&gt;
** They have a length and are indexable.&lt;br /&gt;
**In case of a slice the size does not have to specified in the square bracket.&lt;br /&gt;
**Slices support two in-build functions: copy and append.&lt;br /&gt;
**The program below illustrates the different ways to create slices and use of copy and append.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    arr := [10] int {1,2,3,4,5,6,7,8,9,10}&lt;br /&gt;
    x := make([]int,10) // creates a slice [1...10]&lt;br /&gt;
    y := make([]int,10,10) //creates a slice [1...10]&lt;br /&gt;
    z := arr[0:10] //creates a slice [1...10]&lt;br /&gt;
    s1 := []int{1,2,3,4,5}&lt;br /&gt;
    s2 := append(s1, 6, 7)&lt;br /&gt;
    fmt.Println(s1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(s2) // [1,2,3,4,5,6,7]&lt;br /&gt;
    p1 := [] int{1,2,3,4,5}&lt;br /&gt;
    p2 :=make([]int, 4)&lt;br /&gt;
    copy(p2,p1)&lt;br /&gt;
    fmt.Println(p1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(p2)// [1,2,3,4]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Maps:&lt;br /&gt;
**A map is an unordered collection of key value pairs.&lt;br /&gt;
**Syntax: var x map[int] string , where int is the type of the key and string is the type of the value.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
    x := make(map[int]string)&lt;br /&gt;
    x[1] = one&lt;br /&gt;
    x[2] = two&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
&lt;br /&gt;
*In Go functions can take multiple inputs and return multiple outputs.&lt;br /&gt;
*Go supports a special kind of function called variadic function.&lt;br /&gt;
*Closure is the means by which functions can be created inside other function in Go.&lt;br /&gt;
*Go supports recursive functions.&lt;br /&gt;
*The example below the different types of function in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    display(“Hello World”)&lt;br /&gt;
    sum :=calculateSum(10,20)&lt;br /&gt;
    v1,v2=multipleValues()&lt;br /&gt;
    p=product(5,10,20)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function without return type&lt;br /&gt;
func display( s string) {&lt;br /&gt;
    fmt.Println(s)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns a single value&lt;br /&gt;
func calculateSum(a int, b int) int {&lt;br /&gt;
    c: = a + b&lt;br /&gt;
    return c&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns multiple values&lt;br /&gt;
func multipleValues(int, int) {&lt;br /&gt;
    return 1, 2&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Variadic function&lt;br /&gt;
func product(args ...int) int {&lt;br /&gt;
    p := 1&lt;br /&gt;
   for _, i := range args {&lt;br /&gt;
        p *= i&lt;br /&gt;
   }&lt;br /&gt;
   return p&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pointers==&lt;br /&gt;
It is used to reference a location in the memory where the value is stored rather than containing the value itself. Basic pointer operations in Go are illustrated in the example below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
//Different syntax for pointers&lt;br /&gt;
    &lt;br /&gt;
     ptr1 *int&lt;br /&gt;
     num :=10&lt;br /&gt;
     ptr1 = &amp;amp;num&lt;br /&gt;
     ptr2 := new(int)&lt;br /&gt;
     ptr2=&amp;amp;num&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Concurrency==&lt;br /&gt;
* Go ensures concurrency which allows sharing of state using communication mechanisms.&lt;br /&gt;
* Go provides support for multithreading and CPU parallelization.&lt;br /&gt;
* Go supports asynchrony i.e. allows operations like database and network I/O which are slow operations to occur in parallel along with other operations.&lt;br /&gt;
* A new lightweight process is created using go fund()&lt;br /&gt;
* Channel types are used for providing type safe and synchronized channels between different go routines.&lt;br /&gt;
&lt;br /&gt;
=Users of Go=&lt;br /&gt;
Apart from Google, which uses Go programming for some of its development, companies like [http://en.wikipedia.org/wiki/Dropbox_(service) Dropbox], [http://en.wikipedia.org/wiki/CloudFlare CloudFlare], [http://en.wikipedia.org/wiki/SoundCloud SoundCloud], The BBC, Novartis, Cloud Foundry also use Go programming.  &lt;br /&gt;
Dropbox server (running in the cloud) and desktop client software were primarily written in [http://en.wikipedia.org/wiki/Python_(programming_language) Python]. From mid-2013 Dropbox began migrating its backend infrastructure to Go.&lt;br /&gt;
Some of the open-source applications that are using Go programming are Docker, Flynn, PaaS, Juju, nsq, Doozer e.t.c .&amp;lt;ref name = &amp;quot;GoWIKI&amp;quot;&amp;gt;[http://en.wikipedia.org/wiki/Go_(programming_language), Wikipedia]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advantages=&lt;br /&gt;
 &lt;br /&gt;
*'''C Level Performance'''. golang is within a close margin of the performance level of C code (which is itself an extremely high performance language). It is certainly closer to the performance of native languages than other enterprise level languages such as Java, Scala, Erlang etc.&lt;br /&gt;
 &lt;br /&gt;
*'''Fast Compilation''' is one of the key advantages of Go language. The Golang compiler was designed to compile programs very quickly. Extremely large programs with massively high LOC counts compile seemingly instantly - after all, Golang was designed by Google to solve Google problems, and Google has big problems! At Google, code and CPU cores are both measured in the millions. Go provides a model for software construction that makes dependency analysis easy and avoids much of the overhead of C-style include files and libraries.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reduced compile time is a key improvement in the Go language&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      If A.go depends on B.go depends on C.go :&lt;br /&gt;
         Compile C.go, B.go then A.go normally (other languages)&lt;br /&gt;
         To compile A.go, compiler reads B.o not C.o (go)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At a large scale this should help in hugely speeding up&lt;br /&gt;
&lt;br /&gt;
Other advantages are      &lt;br /&gt;
* '''Concurrency Supported At Language Level'''. Concurrency is the ability to execute multiple computations simultaneously. In today's modern multicore and high-load computing environment, concurrency is a critical language feature, and one in which languages such as Java struggle immensely.&lt;br /&gt;
* By its design, Go proposes an approach for the construction of system software on '''multicore machines'''.&lt;br /&gt;
* Google have summed things up nicely with their motto: '''Don't communicate by sharing memory, share memory by communicating'''.Channels allow you to pass references to data structures between goroutines. If you consider this as passing around ownership of the data (the ability to read and write it), they become a powerful and expressive synchronization mechanism.  &lt;br /&gt;
* '''Go's type system has no hierarchy''', so no time is spent defining the relationships between types. Also, although Go has static types, the language attempts to make types feel lighter weight than in typical Object Oriented languages.&lt;br /&gt;
* '''Garbage Collection is much better'''. In C and C++, programmers spend a lot of time and energy on allocating and freeing memory. The designers of Go wanted to remove that complication, and ensure Go programmers could concentrate on more productive tasks. As such, they implemented garbage collection. As a developer, this is a very good thing. Sure, garbage collection comes with its own set of issues, but those are dealt with by the language implementer while the programmer is free to reap the other many benefits of Go.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
*Go is still an experimental language subject to change.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;&amp;gt;[http://stackoverflow.com/questions/2198529/what-are-the-advantages-and-disadvantages-of-go-programming-language stackoverflow]&amp;lt;/ref&amp;gt;&lt;br /&gt;
*Go's not very usable on Windows yet.&lt;br /&gt;
*The packages distributed with Go are pretty useful, but there are still some libraries you'll miss. Most notably a UI toolkit.&lt;br /&gt;
*There is no support for generics in Go, although there are many discussions around it.&lt;br /&gt;
*Confusing Semantics Of Exported Identifiers&amp;lt;ref name = &amp;quot;Limitations2&amp;quot;&amp;gt;&lt;br /&gt;
[https://functionwhatwhat.com/go’s-type-system-is-an-embarrassment functionwhatwhat ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=87522</id>
		<title>CSC/ECE 517 Fall 2014/ch1a 10 hu</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=87522"/>
		<updated>2014-09-20T01:31:21Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Go Programming Language by Google */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
'''Go''', also commonly referred to as '''golang''', is a compiled, concurrent, garbage-collected, statically typed language developed at [http://en.wikipedia.org/wiki/Google Google]. It was developed by [http://en.wikipedia.org/wiki/Robert_Griesemer Robert Griesemer], [http://en.wikipedia.org/wiki/Rob_Pike Rob Pike] and [http://en.wikipedia.org/wiki/Ken_Thompson Ken Thompson] in 2007. It was announced in November 2009 and is currently being used in many production systems at Google. It is an open source project. The syntax is loosely derived from that of [http://en.wikipedia.org/wiki/C_(programming_language) C programming language], adding [http://en.wikipedia.org/wiki/Garbage_collection_(computer_science) Garbage collection], type safety, some dynamic-typing capabilities. Additional built-in types such as variable-length arrays and key-value maps, and a large standard library are also supported. Different operating systems like Linux, Microsoft Windows, Mac OS X are suported by gc compiler of Go.&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
&lt;br /&gt;
Go programming started of as a research project by Robert Griesemer, Rob Pike and Ken Thompson. They felt that there was no new system focused programming language that has come up in the last decade till 2008, while there were other developments like increase in the size of libraries, dominance of networking , client server focus, multi-core CPUs.&amp;lt;ref name = &amp;quot;Background 1&amp;quot;&amp;gt;[https://www.youtube.com/watch?v=rKnDgT73v8s Go Language Introduction speech]&amp;lt;/ref&amp;gt; So they wanted to come up with a new systems focused programming language that would address the above issues.&amp;lt;ref name=&amp;quot;BG2&amp;quot;&amp;gt;[http://techcrunch.com/2009/11/10/google-go-language TechCrunch]&amp;lt;/ref&amp;gt; They started sketching the goals for a new language on the white board on September 21, 2007. Within a few days the goals had settled into a plan to do something and a fair idea of what it would be. Design continued part-time in parallel with unrelated work.&lt;br /&gt;
By January 2008, Ken had started work on a compiler with which to explore ideas; it generated C code as its output. By mid-year the language had become a full-time project and had settled enough to attempt a production compiler. In May 2008, [http://research.google.com/pubs/author37504.html Ian Taylor] independently started on a [http://en.wikipedia.org/wiki/GNU_Compiler_Collection GCC] front end for Go using the draft specification.  [http://russ.cox.usesthis.com/ Russ Cox] joined in late 2008 and helped move the language and libraries from prototype to reality.&lt;br /&gt;
Go became a public [http://en.wikipedia.org/wiki/Open_source open source project] on November 10, 2009. Many people from the community have contributed ideas, discussions, and code.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Compilers and Runtime support=&lt;br /&gt;
&lt;br /&gt;
There are two Go compiler implementations, [https://golang.org/cmd/gc Gc] (the 6g program and friends) and [http://blog.golang.org/gccgo-in-gcc-471 gccgo ]. Gc uses a different calling convention and linker. It can therefore only be linked with C programs using the same convention. Gccgo is a GCC front-end that can be linked with GCC-compiled C or C++ programs.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cgo program provides the mechanism for a “foreign function interface” to allow safe calling of C libraries from Go code. [http://en.wikipedia.org/wiki/SWIG SWIG] extends this capability to C++ libraries. &lt;br /&gt;
&lt;br /&gt;
Again due to bootstrapping issues, the run-time code is mostly in C (with a tiny bit of assembler) although Go is capable of implementing most of it now. Gccgo's run-time support uses glibc. Gc uses a custom library to keep the footprint under control; it is compiled with a version of the [http://plan9.bell-labs.com/sys/doc/compiler.html Plan 9 C compiler] that supports resizable stacks for goroutines. The gccgo compiler implements these on Linux only, using a technique called segmented stacks, supported by recent modifications to the gold linker.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find all resources needed to compile and run Go Language here http://go-lang.cat-v.org/&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
 &lt;br /&gt;
Programming today involves too much bookkeeping, repetition, and clerical work. As Dick Gabriel says, “Old programs read like quiet conversations between a well-spoken research worker and a well-studied mechanical colleague, not as a debate with a compiler. Who'd have guessed sophistication bought such noise?” The sophistication is worthwhile—no one wants to go back to the old languages—but can it be more quietly achieved?&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Go attempts to reduce the amount of typing in both senses of the word. Throughout its design, &lt;br /&gt;
*They have tried to reduce clutter and complexity. &lt;br /&gt;
*There are no forward declarations and no header files. everything is declared exactly once. &lt;br /&gt;
*Initialization is expressive, automatic, and easy to use. &lt;br /&gt;
*Syntax is clean and light on keywords. Stuttering (foo.Foo* myFoo = new(foo.Foo)) is reduced by simple type derivation using the := declare-and-initialize construct. &lt;br /&gt;
*And perhaps most radically, there is no type hierarchy. They don't have to announce their relationships.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
These simplifications allow Go to be expressive yet comprehensible without sacrificing, well, sophistication.&lt;br /&gt;
Another important principle is to keep the concepts orthogonal. Methods can be implemented for any type; structures represent data while interfaces represent abstraction; and so on. Orthogonality makes it easier to understand what happens when things combine.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Language Design&amp;lt;ref name = &amp;quot;GoLang Book&amp;quot;&amp;gt;[http://www.golang-book.com, GoLang Book]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 package main //line 1&lt;br /&gt;
&lt;br /&gt;
   import “fmt”  //line 2&lt;br /&gt;
&lt;br /&gt;
   func main() {  //line 3&lt;br /&gt;
&lt;br /&gt;
       fmt.Println(“Hello World”) //line 4&lt;br /&gt;
&lt;br /&gt;
   } //line 5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Line1 specifies package declaration. Package is used to organize and reuse code. Line 2 is used for including the package “fmt” which is used for formatting input and output. Line 3 to 5 defines the function main. main is the function which is called when a program is executed. Println function in fmt is used to display content to the console i.e in this example Hello World is displayed in the console on executing the program.&lt;br /&gt;
&lt;br /&gt;
==Code Conventions and Style==&lt;br /&gt;
&lt;br /&gt;
* Go fmt tool is used to automatically standardize indentation, spaces and surface-level code details. go vet and go link are perform checking automatically.&lt;br /&gt;
* Using tools and libraries provided in Go, there are standard approaches for API documentation(go doc), testing(go test), building(go build) and package management(go get).&lt;br /&gt;
* Syntax prevents any kind of cyclic dependencies.&lt;br /&gt;
* Unused variables and imports are not allowed.&lt;br /&gt;
* Elimination of functional programming constructs (such as map and try/finally in C++) ensure a concrete and explicit programming style.&lt;br /&gt;
&lt;br /&gt;
==Types==&lt;br /&gt;
&lt;br /&gt;
* Numbers are represented in Go as either Integers or Floating point numbers.&lt;br /&gt;
**Integers: Used to represent numbers without a decimal component. Different integers supported by Go are: uint8, uint16, uint32, uint64, int8, int16, int32, int64. Uint is used for unsigned integers and int for signed. 8,16, 32, 64 indicate the number of bits each type would use.&lt;br /&gt;
**Floating Point Integers: Used to support decimal components. Go supports float32 and float64 to represent floating point numbers and complex32 and complex64 to represent complex numbers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var x int32 =4&lt;br /&gt;
var y float32 = 4.5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* String: String litersals can be created using either double quotes(“Hello”) or back ticks(`Hello`). Strings have several operations associated them, for example one can find the length of the string or get a character at a specific index in a string.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
	fmt.Println(len(“Hello”)) // output: 5&lt;br /&gt;
	fmt.Println(“Hello”[1]) // output: 1&lt;br /&gt;
	fmt.Println(“Hello “+”Tom”) //output: Hello Tom&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Boolean: A 1 bit value is used to represent true or false.&lt;br /&gt;
&lt;br /&gt;
==Variables and Constants==&lt;br /&gt;
*Variabes in Go are indicated using the var keyword. Example: var x string=”hello” . They can also be shorthanded as x:=”hello” .&lt;br /&gt;
*The variable names should begin with a letter and can contain letters, digits or underscore character.&lt;br /&gt;
*The scope of the variable is the block in which it is defined and an attempt to access it outside the block would result in an error on running the program.&lt;br /&gt;
*Go provides support for constants (i.e. variables whose value can not be changed), using the const keyword. Example: const temp string = “Hello”&lt;br /&gt;
*In Go one can define multiple variables(or constants) using the following syntax:&lt;br /&gt;
    var(&lt;br /&gt;
         t1 =1&lt;br /&gt;
         t2=2&lt;br /&gt;
         t3=3&lt;br /&gt;
        t4=4&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Control Structures==&lt;br /&gt;
*For: It is used for repeating a list of statement(s) multiple times. The example below is used for calculating sum of numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    i := 1&lt;br /&gt;
    sum := 0&lt;br /&gt;
&lt;br /&gt;
    for i &amp;lt;= 10 {&lt;br /&gt;
        sum = sum + i&lt;br /&gt;
        i = i + 1&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    fmt.Println(“Sum:” + sum)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the example above i is a loop counter variable and is used to ensure that sum of numbers from 1 to 10 is computed. It indicates the number of times the statements inside the for loop is to be executed. The statement following the keyword for should evaluate to either true or false. If it is evaluated to true the body of for is executed, else we come out of the for loop.&lt;br /&gt;
&lt;br /&gt;
*If: Used to execute a block of statement(s) based on the evaluation of an expression to either true or false. It can also have an else associated with it.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    if i % 2 == 0 {&lt;br /&gt;
        fmt.Println(i + ” is divisble by 2”)&lt;br /&gt;
    } else {&lt;br /&gt;
        fmt.Println(i + “is not divisible by 2”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Switch: The value of the expression following switch is evaluated and is compared against the different cases. Based on the matching case, the block following that case is executed. Switch also has a default case in situations when none of the cases are matching.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    // if op ==1 then so a+b&lt;br /&gt;
    // if op == 2 then do a-b&lt;br /&gt;
    // if op == 3 then do a*b&lt;br /&gt;
    // if op ==4 then do a/b&lt;br /&gt;
    // default print, invalid operator&lt;br /&gt;
&lt;br /&gt;
    op:= 1&lt;br /&gt;
    a=6&lt;br /&gt;
    b=7&lt;br /&gt;
    switch(op) {&lt;br /&gt;
        case 1: fmt.Println(a+b)&lt;br /&gt;
        case 2: fmt.Println(a-b)&lt;br /&gt;
        case 3: fmt.Println(a*b)&lt;br /&gt;
        case 4: fmt.Println(a/b)&lt;br /&gt;
        default: fmt.Println(“Invalid Operator”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Arrays, Slices and Maps==&lt;br /&gt;
&lt;br /&gt;
*Arrays: Numbered sequence of elements starting with index zero and each of the elements having a fixed length. The example below illustrates various operations performed on arrays in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
    var x[10] int&lt;br /&gt;
    x[99]=100&lt;br /&gt;
    fmt.Println(x)  //[0 0 ….. 0 100]&lt;br /&gt;
    fmt.Println(len(x)) //100&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Slices: &lt;br /&gt;
** It is a segment of an array.&lt;br /&gt;
** They have a length and are indexable.&lt;br /&gt;
**In case of a slice the size does not have to specified in the square bracket.&lt;br /&gt;
**Slices support two in-build functions: copy and append.&lt;br /&gt;
**The program below illustrates the different ways to create slices and use of copy and append.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    arr := [10] int {1,2,3,4,5,6,7,8,9,10}&lt;br /&gt;
    x := make([]int,10) // creates a slice [1...10]&lt;br /&gt;
    y := make([]int,10,10) //creates a slice [1...10]&lt;br /&gt;
    z := arr[0:10] //creates a slice [1...10]&lt;br /&gt;
    s1 := []int{1,2,3,4,5}&lt;br /&gt;
    s2 := append(s1, 6, 7)&lt;br /&gt;
    fmt.Println(s1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(s2) // [1,2,3,4,5,6,7]&lt;br /&gt;
    p1 := [] int{1,2,3,4,5}&lt;br /&gt;
    p2 :=make([]int, 4)&lt;br /&gt;
    copy(p2,p1)&lt;br /&gt;
    fmt.Println(p1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(p2)// [1,2,3,4]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Maps:&lt;br /&gt;
**A map is an unordered collection of key value pairs.&lt;br /&gt;
**Syntax: var x map[int] string , where int is the type of the key and string is the type of the value.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
    x := make(map[int]string)&lt;br /&gt;
    x[1] = one&lt;br /&gt;
    x[2] = two&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
&lt;br /&gt;
*In Go functions can take multiple inputs and return multiple outputs.&lt;br /&gt;
*Go supports a special kind of function called variadic function.&lt;br /&gt;
*Closure is the means by which functions can be created inside other function in Go.&lt;br /&gt;
*Go supports recursive functions.&lt;br /&gt;
*The example below the different types of function in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    display(“Hello World”)&lt;br /&gt;
    sum :=calculateSum(10,20)&lt;br /&gt;
    v1,v2=multipleValues()&lt;br /&gt;
    p=product(5,10,20)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function without return type&lt;br /&gt;
func display( s string) {&lt;br /&gt;
    fmt.Println(s)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns a single value&lt;br /&gt;
func calculateSum(a int, b int) int {&lt;br /&gt;
    c: = a + b&lt;br /&gt;
    return c&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns multiple values&lt;br /&gt;
func multipleValues(int, int) {&lt;br /&gt;
    return 1, 2&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Variadic function&lt;br /&gt;
func product(args ...int) int {&lt;br /&gt;
    p := 1&lt;br /&gt;
   for _, i := range args {&lt;br /&gt;
        p *= i&lt;br /&gt;
   }&lt;br /&gt;
   return p&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pointers==&lt;br /&gt;
It is used to reference a location in the memory where the value is stored rather than containing the value itself. Basic pointer operations in Go are illustrated in the example below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
//Different syntax for pointers&lt;br /&gt;
    &lt;br /&gt;
     ptr1 *int&lt;br /&gt;
     num :=10&lt;br /&gt;
     ptr1 = &amp;amp;num&lt;br /&gt;
     ptr2 := new(int)&lt;br /&gt;
     ptr2=&amp;amp;num&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Concurrency==&lt;br /&gt;
* Go ensures concurrency which allows sharing of state using communication mechanisms.&lt;br /&gt;
* Go provides support for multithreading and CPU parallelization.&lt;br /&gt;
* Go supports asynchrony i.e. allows operations like database and network I/O which are slow operations to occur in parallel along with other operations.&lt;br /&gt;
* A new lightweight process is created using go fund()&lt;br /&gt;
* Channel types are used for providing type safe and synchronized channels between different go routines.&lt;br /&gt;
&lt;br /&gt;
=Users of Go=&lt;br /&gt;
Apart from Google, which uses Go programming for some of its development, companies like [http://en.wikipedia.org/wiki/Dropbox_(service) Dropbox], [http://en.wikipedia.org/wiki/CloudFlare CloudFlare], [http://en.wikipedia.org/wiki/SoundCloud SoundCloud], The BBC, Novartis, Cloud Foundry also use Go programming.  &lt;br /&gt;
Dropbox server (running in the cloud) and desktop client software were primarily written in [http://en.wikipedia.org/wiki/Python_(programming_language) Python]. From mid-2013 Dropbox began migrating its backend infrastructure to Go.&lt;br /&gt;
Some of the open-source applications that are using Go programming are Docker, Flynn, PaaS, Juju, nsq, Doozer e.t.c .&amp;lt;ref name = &amp;quot;GoWIKI&amp;quot;&amp;gt;[http://en.wikipedia.org/wiki/Go_(programming_language), Wikipedia]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advantages=&lt;br /&gt;
 &lt;br /&gt;
*'''C Level Performance'''. golang is within a close margin of the performance level of C code (which is itself an extremely high performance language). It is certainly closer to the performance of native languages than other enterprise level languages such as Java, Scala, Erlang etc.&lt;br /&gt;
 &lt;br /&gt;
*'''Fast Compilation''' is one of the key advantages of Go language. The Golang compiler was designed to compile programs very quickly. Extremely large programs with massively high LOC counts compile seemingly instantly - after all, Golang was designed by Google to solve Google problems, and Google has big problems! At Google, code and CPU cores are both measured in the millions. Go provides a model for software construction that makes dependency analysis easy and avoids much of the overhead of C-style include files and libraries.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reduced compile time is a key improvement in the Go language&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      If A.go depends on B.go depends on C.go :&lt;br /&gt;
         Compile C.go, B.go then A.go normally (other languages)&lt;br /&gt;
         To compile A.go, compiler reads B.o not C.o (go)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At a large scale this should help in hugely speeding up&lt;br /&gt;
&lt;br /&gt;
Other advantages are      &lt;br /&gt;
* '''Concurrency Supported At Language Level'''. Concurrency is the ability to execute multiple computations simultaneously. In today's modern multicore and high-load computing environment, concurrency is a critical language feature, and one in which languages such as Java struggle immensely.&lt;br /&gt;
* By its design, Go proposes an approach for the construction of system software on '''multicore machines'''.&lt;br /&gt;
* Google have summed things up nicely with their motto: '''Don't communicate by sharing memory, share memory by communicating'''.Channels allow you to pass references to data structures between goroutines. If you consider this as passing around ownership of the data (the ability to read and write it), they become a powerful and expressive synchronization mechanism.  &lt;br /&gt;
* '''Go's type system has no hierarchy''', so no time is spent defining the relationships between types. Also, although Go has static types, the language attempts to make types feel lighter weight than in typical Object Oriented languages.&lt;br /&gt;
* '''Garbage Collection is much better'''. In C and C++, programmers spend a lot of time and energy on allocating and freeing memory. The designers of Go wanted to remove that complication, and ensure Go programmers could concentrate on more productive tasks. As such, they implemented garbage collection. As a developer, this is a very good thing. Sure, garbage collection comes with its own set of issues, but those are dealt with by the language implementer while the programmer is free to reap the other many benefits of Go.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
*Go is still an experimental language subject to change.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;&amp;gt;[http://stackoverflow.com/questions/2198529/what-are-the-advantages-and-disadvantages-of-go-programming-language stackoverflow]&amp;lt;/ref&amp;gt;&lt;br /&gt;
*Go's not very usable on Windows yet.&lt;br /&gt;
*The packages distributed with Go are pretty useful, but there are still some libraries you'll miss. Most notably a UI toolkit.&lt;br /&gt;
*There is no support for generics in Go, although there are many discussions around it.&lt;br /&gt;
*Confusing Semantics Of Exported Identifiers&amp;lt;ref name = &amp;quot;Limitations2&amp;quot;&amp;gt;&lt;br /&gt;
[https://functionwhatwhat.com/go’s-type-system-is-an-embarrassment functionwhatwhat ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=87516</id>
		<title>CSC/ECE 517 Fall 2014/ch1a 10 hu</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=87516"/>
		<updated>2014-09-20T01:30:09Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Go Programming Language by Google */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Go Programming Language by Google =&lt;br /&gt;
&lt;br /&gt;
'''Go''', also commonly referred to as '''golang''', is a compiled, concurrent, garbage-collected, statically typed language developed at [http://en.wikipedia.org/wiki/Google Google]. It was developed by [http://en.wikipedia.org/wiki/Robert_Griesemer Robert Griesemer], [http://en.wikipedia.org/wiki/Rob_Pike Rob Pike] and [http://en.wikipedia.org/wiki/Ken_Thompson Ken Thompson] in 2007. It was announced in November 2009 and is currently being used in many production systems at Google. It is an open source project. The syntax is loosely derived from that of [http://en.wikipedia.org/wiki/C_(programming_language) C programming language], adding [http://en.wikipedia.org/wiki/Garbage_collection_(computer_science) Garbage collection], type safety, some dynamic-typing capabilities. Additional built-in types such as variable-length arrays and key-value maps, and a large standard library are also supported. Different operating systems like Linux, Microsoft Windows, Mac OS X are suported by gc compiler of Go.&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
&lt;br /&gt;
Go programming started of as a research project by Robert Griesemer, Rob Pike and Ken Thompson. They felt that there was no new system focused programming language that has come up in the last decade till 2008, while there were other developments like increase in the size of libraries, dominance of networking , client server focus, multi-core CPUs.&amp;lt;ref name = &amp;quot;Background 1&amp;quot;&amp;gt;[https://www.youtube.com/watch?v=rKnDgT73v8s Go Language Introduction speech]&amp;lt;/ref&amp;gt; So they wanted to come up with a new systems focused programming language that would address the above issues.&amp;lt;ref name=&amp;quot;BG2&amp;quot;&amp;gt;[http://techcrunch.com/2009/11/10/google-go-language TechCrunch]&amp;lt;/ref&amp;gt; They started sketching the goals for a new language on the white board on September 21, 2007. Within a few days the goals had settled into a plan to do something and a fair idea of what it would be. Design continued part-time in parallel with unrelated work.&lt;br /&gt;
By January 2008, Ken had started work on a compiler with which to explore ideas; it generated C code as its output. By mid-year the language had become a full-time project and had settled enough to attempt a production compiler. In May 2008, [http://research.google.com/pubs/author37504.html Ian Taylor] independently started on a [http://en.wikipedia.org/wiki/GNU_Compiler_Collection GCC] front end for Go using the draft specification.  [http://russ.cox.usesthis.com/ Russ Cox] joined in late 2008 and helped move the language and libraries from prototype to reality.&lt;br /&gt;
Go became a public [http://en.wikipedia.org/wiki/Open_source open source project] on November 10, 2009. Many people from the community have contributed ideas, discussions, and code.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Compilers and Runtime support=&lt;br /&gt;
&lt;br /&gt;
There are two Go compiler implementations, [https://golang.org/cmd/gc Gc] (the 6g program and friends) and [http://blog.golang.org/gccgo-in-gcc-471 gccgo ]. Gc uses a different calling convention and linker. It can therefore only be linked with C programs using the same convention. Gccgo is a GCC front-end that can be linked with GCC-compiled C or C++ programs.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cgo program provides the mechanism for a “foreign function interface” to allow safe calling of C libraries from Go code. [http://en.wikipedia.org/wiki/SWIG SWIG] extends this capability to C++ libraries. &lt;br /&gt;
&lt;br /&gt;
Again due to bootstrapping issues, the run-time code is mostly in C (with a tiny bit of assembler) although Go is capable of implementing most of it now. Gccgo's run-time support uses glibc. Gc uses a custom library to keep the footprint under control; it is compiled with a version of the [http://plan9.bell-labs.com/sys/doc/compiler.html Plan 9 C compiler] that supports resizable stacks for goroutines. The gccgo compiler implements these on Linux only, using a technique called segmented stacks, supported by recent modifications to the gold linker.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find all resources needed to compile and run Go Language here http://go-lang.cat-v.org/&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
 &lt;br /&gt;
Programming today involves too much bookkeeping, repetition, and clerical work. As Dick Gabriel says, “Old programs read like quiet conversations between a well-spoken research worker and a well-studied mechanical colleague, not as a debate with a compiler. Who'd have guessed sophistication bought such noise?” The sophistication is worthwhile—no one wants to go back to the old languages—but can it be more quietly achieved?&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Go attempts to reduce the amount of typing in both senses of the word. Throughout its design, &lt;br /&gt;
*They have tried to reduce clutter and complexity. &lt;br /&gt;
*There are no forward declarations and no header files. everything is declared exactly once. &lt;br /&gt;
*Initialization is expressive, automatic, and easy to use. &lt;br /&gt;
*Syntax is clean and light on keywords. Stuttering (foo.Foo* myFoo = new(foo.Foo)) is reduced by simple type derivation using the := declare-and-initialize construct. &lt;br /&gt;
*And perhaps most radically, there is no type hierarchy. They don't have to announce their relationships.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
These simplifications allow Go to be expressive yet comprehensible without sacrificing, well, sophistication.&lt;br /&gt;
Another important principle is to keep the concepts orthogonal. Methods can be implemented for any type; structures represent data while interfaces represent abstraction; and so on. Orthogonality makes it easier to understand what happens when things combine.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Language Design&amp;lt;ref name = &amp;quot;GoLang Book&amp;quot;&amp;gt;[http://www.golang-book.com, GoLang Book]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 package main //line 1&lt;br /&gt;
&lt;br /&gt;
   import “fmt”  //line 2&lt;br /&gt;
&lt;br /&gt;
   func main() {  //line 3&lt;br /&gt;
&lt;br /&gt;
       fmt.Println(“Hello World”) //line 4&lt;br /&gt;
&lt;br /&gt;
   } //line 5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Line1 specifies package declaration. Package is used to organize and reuse code. Line 2 is used for including the package “fmt” which is used for formatting input and output. Line 3 to 5 defines the function main. main is the function which is called when a program is executed. Println function in fmt is used to display content to the console i.e in this example Hello World is displayed in the console on executing the program.&lt;br /&gt;
&lt;br /&gt;
==Code Conventions and Style==&lt;br /&gt;
&lt;br /&gt;
* Go fmt tool is used to automatically standardize indentation, spaces and surface-level code details. go vet and go link are perform checking automatically.&lt;br /&gt;
* Using tools and libraries provided in Go, there are standard approaches for API documentation(go doc), testing(go test), building(go build) and package management(go get).&lt;br /&gt;
* Syntax prevents any kind of cyclic dependencies.&lt;br /&gt;
* Unused variables and imports are not allowed.&lt;br /&gt;
* Elimination of functional programming constructs (such as map and try/finally in C++) ensure a concrete and explicit programming style.&lt;br /&gt;
&lt;br /&gt;
==Types==&lt;br /&gt;
&lt;br /&gt;
* Numbers are represented in Go as either Integers or Floating point numbers.&lt;br /&gt;
**Integers: Used to represent numbers without a decimal component. Different integers supported by Go are: uint8, uint16, uint32, uint64, int8, int16, int32, int64. Uint is used for unsigned integers and int for signed. 8,16, 32, 64 indicate the number of bits each type would use.&lt;br /&gt;
**Floating Point Integers: Used to support decimal components. Go supports float32 and float64 to represent floating point numbers and complex32 and complex64 to represent complex numbers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var x int32 =4&lt;br /&gt;
var y float32 = 4.5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* String: String litersals can be created using either double quotes(“Hello”) or back ticks(`Hello`). Strings have several operations associated them, for example one can find the length of the string or get a character at a specific index in a string.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
	fmt.Println(len(“Hello”)) // output: 5&lt;br /&gt;
	fmt.Println(“Hello”[1]) // output: 1&lt;br /&gt;
	fmt.Println(“Hello “+”Tom”) //output: Hello Tom&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Boolean: A 1 bit value is used to represent true or false.&lt;br /&gt;
&lt;br /&gt;
==Variables and Constants==&lt;br /&gt;
*Variabes in Go are indicated using the var keyword. Example: var x string=”hello” . They can also be shorthanded as x:=”hello” .&lt;br /&gt;
*The variable names should begin with a letter and can contain letters, digits or underscore character.&lt;br /&gt;
*The scope of the variable is the block in which it is defined and an attempt to access it outside the block would result in an error on running the program.&lt;br /&gt;
*Go provides support for constants (i.e. variables whose value can not be changed), using the const keyword. Example: const temp string = “Hello”&lt;br /&gt;
*In Go one can define multiple variables(or constants) using the following syntax:&lt;br /&gt;
    var(&lt;br /&gt;
         t1 =1&lt;br /&gt;
         t2=2&lt;br /&gt;
         t3=3&lt;br /&gt;
        t4=4&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Control Structures==&lt;br /&gt;
*For: It is used for repeating a list of statement(s) multiple times. The example below is used for calculating sum of numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    i := 1&lt;br /&gt;
    sum := 0&lt;br /&gt;
&lt;br /&gt;
    for i &amp;lt;= 10 {&lt;br /&gt;
        sum = sum + i&lt;br /&gt;
        i = i + 1&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    fmt.Println(“Sum:” + sum)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the example above i is a loop counter variable and is used to ensure that sum of numbers from 1 to 10 is computed. It indicates the number of times the statements inside the for loop is to be executed. The statement following the keyword for should evaluate to either true or false. If it is evaluated to true the body of for is executed, else we come out of the for loop.&lt;br /&gt;
&lt;br /&gt;
*If: Used to execute a block of statement(s) based on the evaluation of an expression to either true or false. It can also have an else associated with it.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    if i % 2 == 0 {&lt;br /&gt;
        fmt.Println(i + ” is divisble by 2”)&lt;br /&gt;
    } else {&lt;br /&gt;
        fmt.Println(i + “is not divisible by 2”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Switch: The value of the expression following switch is evaluated and is compared against the different cases. Based on the matching case, the block following that case is executed. Switch also has a default case in situations when none of the cases are matching.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    // if op ==1 then so a+b&lt;br /&gt;
    // if op == 2 then do a-b&lt;br /&gt;
    // if op == 3 then do a*b&lt;br /&gt;
    // if op ==4 then do a/b&lt;br /&gt;
    // default print, invalid operator&lt;br /&gt;
&lt;br /&gt;
    op:= 1&lt;br /&gt;
    a=6&lt;br /&gt;
    b=7&lt;br /&gt;
    switch(op) {&lt;br /&gt;
        case 1: fmt.Println(a+b)&lt;br /&gt;
        case 2: fmt.Println(a-b)&lt;br /&gt;
        case 3: fmt.Println(a*b)&lt;br /&gt;
        case 4: fmt.Println(a/b)&lt;br /&gt;
        default: fmt.Println(“Invalid Operator”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Arrays, Slices and Maps==&lt;br /&gt;
&lt;br /&gt;
*Arrays: Numbered sequence of elements starting with index zero and each of the elements having a fixed length. The example below illustrates various operations performed on arrays in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
    var x[10] int&lt;br /&gt;
    x[99]=100&lt;br /&gt;
    fmt.Println(x)  //[0 0 ….. 0 100]&lt;br /&gt;
    fmt.Println(len(x)) //100&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Slices: &lt;br /&gt;
** It is a segment of an array.&lt;br /&gt;
** They have a length and are indexable.&lt;br /&gt;
**In case of a slice the size does not have to specified in the square bracket.&lt;br /&gt;
**Slices support two in-build functions: copy and append.&lt;br /&gt;
**The program below illustrates the different ways to create slices and use of copy and append.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    arr := [10] int {1,2,3,4,5,6,7,8,9,10}&lt;br /&gt;
    x := make([]int,10) // creates a slice [1...10]&lt;br /&gt;
    y := make([]int,10,10) //creates a slice [1...10]&lt;br /&gt;
    z := arr[0:10] //creates a slice [1...10]&lt;br /&gt;
    s1 := []int{1,2,3,4,5}&lt;br /&gt;
    s2 := append(s1, 6, 7)&lt;br /&gt;
    fmt.Println(s1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(s2) // [1,2,3,4,5,6,7]&lt;br /&gt;
    p1 := [] int{1,2,3,4,5}&lt;br /&gt;
    p2 :=make([]int, 4)&lt;br /&gt;
    copy(p2,p1)&lt;br /&gt;
    fmt.Println(p1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(p2)// [1,2,3,4]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Maps:&lt;br /&gt;
**A map is an unordered collection of key value pairs.&lt;br /&gt;
**Syntax: var x map[int] string , where int is the type of the key and string is the type of the value.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
    x := make(map[int]string)&lt;br /&gt;
    x[1] = one&lt;br /&gt;
    x[2] = two&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
&lt;br /&gt;
*In Go functions can take multiple inputs and return multiple outputs.&lt;br /&gt;
*Go supports a special kind of function called variadic function.&lt;br /&gt;
*Closure is the means by which functions can be created inside other function in Go.&lt;br /&gt;
*Go supports recursive functions.&lt;br /&gt;
*The example below the different types of function in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    display(“Hello World”)&lt;br /&gt;
    sum :=calculateSum(10,20)&lt;br /&gt;
    v1,v2=multipleValues()&lt;br /&gt;
    p=product(5,10,20)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function without return type&lt;br /&gt;
func display( s string) {&lt;br /&gt;
    fmt.Println(s)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns a single value&lt;br /&gt;
func calculateSum(a int, b int) int {&lt;br /&gt;
    c: = a + b&lt;br /&gt;
    return c&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns multiple values&lt;br /&gt;
func multipleValues(int, int) {&lt;br /&gt;
    return 1, 2&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Variadic function&lt;br /&gt;
func product(args ...int) int {&lt;br /&gt;
    p := 1&lt;br /&gt;
   for _, i := range args {&lt;br /&gt;
        p *= i&lt;br /&gt;
   }&lt;br /&gt;
   return p&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pointers==&lt;br /&gt;
It is used to reference a location in the memory where the value is stored rather than containing the value itself. Basic pointer operations in Go are illustrated in the example below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
//Different syntax for pointers&lt;br /&gt;
    &lt;br /&gt;
     ptr1 *int&lt;br /&gt;
     num :=10&lt;br /&gt;
     ptr1 = &amp;amp;num&lt;br /&gt;
     ptr2 := new(int)&lt;br /&gt;
     ptr2=&amp;amp;num&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Concurrency==&lt;br /&gt;
* Go ensures concurrency which allows sharing of state using communication mechanisms.&lt;br /&gt;
* Go provides support for multithreading and CPU parallelization.&lt;br /&gt;
* Go supports asynchrony i.e. allows operations like database and network I/O which are slow operations to occur in parallel along with other operations.&lt;br /&gt;
* A new lightweight process is created using go fund()&lt;br /&gt;
* Channel types are used for providing type safe and synchronized channels between different go routines.&lt;br /&gt;
&lt;br /&gt;
=Users of Go=&lt;br /&gt;
Apart from Google, which uses Go programming for some of its development, companies like [http://en.wikipedia.org/wiki/Dropbox_(service) Dropbox], [http://en.wikipedia.org/wiki/CloudFlare CloudFlare], [http://en.wikipedia.org/wiki/SoundCloud SoundCloud], The BBC, Novartis, Cloud Foundry also use Go programming.  &lt;br /&gt;
Dropbox server (running in the cloud) and desktop client software were primarily written in [http://en.wikipedia.org/wiki/Python_(programming_language) Python]. From mid-2013 Dropbox began migrating its backend infrastructure to Go.&lt;br /&gt;
Some of the open-source applications that are using Go programming are Docker, Flynn, PaaS, Juju, nsq, Doozer e.t.c .&amp;lt;ref name = &amp;quot;GoWIKI&amp;quot;&amp;gt;[http://en.wikipedia.org/wiki/Go_(programming_language), Wikipedia]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advantages=&lt;br /&gt;
 &lt;br /&gt;
*'''C Level Performance'''. golang is within a close margin of the performance level of C code (which is itself an extremely high performance language). It is certainly closer to the performance of native languages than other enterprise level languages such as Java, Scala, Erlang etc.&lt;br /&gt;
 &lt;br /&gt;
*'''Fast Compilation''' is one of the key advantages of Go language. The Golang compiler was designed to compile programs very quickly. Extremely large programs with massively high LOC counts compile seemingly instantly - after all, Golang was designed by Google to solve Google problems, and Google has big problems! At Google, code and CPU cores are both measured in the millions. Go provides a model for software construction that makes dependency analysis easy and avoids much of the overhead of C-style include files and libraries.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reduced compile time is a key improvement in the Go language&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      If A.go depends on B.go depends on C.go :&lt;br /&gt;
         Compile C.go, B.go then A.go normally (other languages)&lt;br /&gt;
         To compile A.go, compiler reads B.o not C.o (go)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At a large scale this should help in hugely speeding up&lt;br /&gt;
&lt;br /&gt;
Other advantages are      &lt;br /&gt;
* '''Concurrency Supported At Language Level'''. Concurrency is the ability to execute multiple computations simultaneously. In today's modern multicore and high-load computing environment, concurrency is a critical language feature, and one in which languages such as Java struggle immensely.&lt;br /&gt;
* By its design, Go proposes an approach for the construction of system software on '''multicore machines'''.&lt;br /&gt;
* Google have summed things up nicely with their motto: '''Don't communicate by sharing memory, share memory by communicating'''.Channels allow you to pass references to data structures between goroutines. If you consider this as passing around ownership of the data (the ability to read and write it), they become a powerful and expressive synchronization mechanism.  &lt;br /&gt;
* '''Go's type system has no hierarchy''', so no time is spent defining the relationships between types. Also, although Go has static types, the language attempts to make types feel lighter weight than in typical Object Oriented languages.&lt;br /&gt;
* '''Garbage Collection is much better'''. In C and C++, programmers spend a lot of time and energy on allocating and freeing memory. The designers of Go wanted to remove that complication, and ensure Go programmers could concentrate on more productive tasks. As such, they implemented garbage collection. As a developer, this is a very good thing. Sure, garbage collection comes with its own set of issues, but those are dealt with by the language implementer while the programmer is free to reap the other many benefits of Go.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
*Go is still an experimental language subject to change.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;&amp;gt;[http://stackoverflow.com/questions/2198529/what-are-the-advantages-and-disadvantages-of-go-programming-language stackoverflow]&amp;lt;/ref&amp;gt;&lt;br /&gt;
*Go's not very usable on Windows yet.&lt;br /&gt;
*The packages distributed with Go are pretty useful, but there are still some libraries you'll miss. Most notably a UI toolkit.&lt;br /&gt;
*There is no support for generics in Go, although there are many discussions around it.&lt;br /&gt;
*Confusing Semantics Of Exported Identifiers&amp;lt;ref name = &amp;quot;Limitations2&amp;quot;&amp;gt;&lt;br /&gt;
[https://functionwhatwhat.com/go’s-type-system-is-an-embarrassment functionwhatwhat ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=87515</id>
		<title>CSC/ECE 517 Fall 2014/ch1a 10 hu</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=87515"/>
		<updated>2014-09-20T01:29:38Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Go Programming Language by Google ==&lt;br /&gt;
&lt;br /&gt;
'''Go''', also commonly referred to as '''golang''', is a compiled, concurrent, garbage-collected, statically typed language developed at [http://en.wikipedia.org/wiki/Google Google]. It was developed by [http://en.wikipedia.org/wiki/Robert_Griesemer Robert Griesemer], [http://en.wikipedia.org/wiki/Rob_Pike Rob Pike] and [http://en.wikipedia.org/wiki/Ken_Thompson Ken Thompson] in 2007. It was announced in November 2009 and is currently being used in many production systems at Google. It is an open source project. The syntax is loosely derived from that of [http://en.wikipedia.org/wiki/C_(programming_language) C programming language], adding [http://en.wikipedia.org/wiki/Garbage_collection_(computer_science) Garbage collection], type safety, some dynamic-typing capabilities. Additional built-in types such as variable-length arrays and key-value maps, and a large standard library are also supported. Different operating systems like Linux, Microsoft Windows, Mac OS X are suported by gc compiler of Go.&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
&lt;br /&gt;
Go programming started of as a research project by Robert Griesemer, Rob Pike and Ken Thompson. They felt that there was no new system focused programming language that has come up in the last decade till 2008, while there were other developments like increase in the size of libraries, dominance of networking , client server focus, multi-core CPUs.&amp;lt;ref name = &amp;quot;Background 1&amp;quot;&amp;gt;[https://www.youtube.com/watch?v=rKnDgT73v8s Go Language Introduction speech]&amp;lt;/ref&amp;gt; So they wanted to come up with a new systems focused programming language that would address the above issues.&amp;lt;ref name=&amp;quot;BG2&amp;quot;&amp;gt;[http://techcrunch.com/2009/11/10/google-go-language TechCrunch]&amp;lt;/ref&amp;gt; They started sketching the goals for a new language on the white board on September 21, 2007. Within a few days the goals had settled into a plan to do something and a fair idea of what it would be. Design continued part-time in parallel with unrelated work.&lt;br /&gt;
By January 2008, Ken had started work on a compiler with which to explore ideas; it generated C code as its output. By mid-year the language had become a full-time project and had settled enough to attempt a production compiler. In May 2008, [http://research.google.com/pubs/author37504.html Ian Taylor] independently started on a [http://en.wikipedia.org/wiki/GNU_Compiler_Collection GCC] front end for Go using the draft specification.  [http://russ.cox.usesthis.com/ Russ Cox] joined in late 2008 and helped move the language and libraries from prototype to reality.&lt;br /&gt;
Go became a public [http://en.wikipedia.org/wiki/Open_source open source project] on November 10, 2009. Many people from the community have contributed ideas, discussions, and code.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Compilers and Runtime support=&lt;br /&gt;
&lt;br /&gt;
There are two Go compiler implementations, [https://golang.org/cmd/gc Gc] (the 6g program and friends) and [http://blog.golang.org/gccgo-in-gcc-471 gccgo ]. Gc uses a different calling convention and linker. It can therefore only be linked with C programs using the same convention. Gccgo is a GCC front-end that can be linked with GCC-compiled C or C++ programs.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cgo program provides the mechanism for a “foreign function interface” to allow safe calling of C libraries from Go code. [http://en.wikipedia.org/wiki/SWIG SWIG] extends this capability to C++ libraries. &lt;br /&gt;
&lt;br /&gt;
Again due to bootstrapping issues, the run-time code is mostly in C (with a tiny bit of assembler) although Go is capable of implementing most of it now. Gccgo's run-time support uses glibc. Gc uses a custom library to keep the footprint under control; it is compiled with a version of the [http://plan9.bell-labs.com/sys/doc/compiler.html Plan 9 C compiler] that supports resizable stacks for goroutines. The gccgo compiler implements these on Linux only, using a technique called segmented stacks, supported by recent modifications to the gold linker.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find all resources needed to compile and run Go Language here http://go-lang.cat-v.org/&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
 &lt;br /&gt;
Programming today involves too much bookkeeping, repetition, and clerical work. As Dick Gabriel says, “Old programs read like quiet conversations between a well-spoken research worker and a well-studied mechanical colleague, not as a debate with a compiler. Who'd have guessed sophistication bought such noise?” The sophistication is worthwhile—no one wants to go back to the old languages—but can it be more quietly achieved?&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Go attempts to reduce the amount of typing in both senses of the word. Throughout its design, &lt;br /&gt;
*They have tried to reduce clutter and complexity. &lt;br /&gt;
*There are no forward declarations and no header files. everything is declared exactly once. &lt;br /&gt;
*Initialization is expressive, automatic, and easy to use. &lt;br /&gt;
*Syntax is clean and light on keywords. Stuttering (foo.Foo* myFoo = new(foo.Foo)) is reduced by simple type derivation using the := declare-and-initialize construct. &lt;br /&gt;
*And perhaps most radically, there is no type hierarchy. They don't have to announce their relationships.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
These simplifications allow Go to be expressive yet comprehensible without sacrificing, well, sophistication.&lt;br /&gt;
Another important principle is to keep the concepts orthogonal. Methods can be implemented for any type; structures represent data while interfaces represent abstraction; and so on. Orthogonality makes it easier to understand what happens when things combine.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Language Design&amp;lt;ref name = &amp;quot;GoLang Book&amp;quot;&amp;gt;[http://www.golang-book.com, GoLang Book]&amp;lt;/ref&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 package main //line 1&lt;br /&gt;
&lt;br /&gt;
   import “fmt”  //line 2&lt;br /&gt;
&lt;br /&gt;
   func main() {  //line 3&lt;br /&gt;
&lt;br /&gt;
       fmt.Println(“Hello World”) //line 4&lt;br /&gt;
&lt;br /&gt;
   } //line 5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Line1 specifies package declaration. Package is used to organize and reuse code. Line 2 is used for including the package “fmt” which is used for formatting input and output. Line 3 to 5 defines the function main. main is the function which is called when a program is executed. Println function in fmt is used to display content to the console i.e in this example Hello World is displayed in the console on executing the program.&lt;br /&gt;
&lt;br /&gt;
==Code Conventions and Style==&lt;br /&gt;
&lt;br /&gt;
* Go fmt tool is used to automatically standardize indentation, spaces and surface-level code details. go vet and go link are perform checking automatically.&lt;br /&gt;
* Using tools and libraries provided in Go, there are standard approaches for API documentation(go doc), testing(go test), building(go build) and package management(go get).&lt;br /&gt;
* Syntax prevents any kind of cyclic dependencies.&lt;br /&gt;
* Unused variables and imports are not allowed.&lt;br /&gt;
* Elimination of functional programming constructs (such as map and try/finally in C++) ensure a concrete and explicit programming style.&lt;br /&gt;
&lt;br /&gt;
==Types==&lt;br /&gt;
&lt;br /&gt;
* Numbers are represented in Go as either Integers or Floating point numbers.&lt;br /&gt;
**Integers: Used to represent numbers without a decimal component. Different integers supported by Go are: uint8, uint16, uint32, uint64, int8, int16, int32, int64. Uint is used for unsigned integers and int for signed. 8,16, 32, 64 indicate the number of bits each type would use.&lt;br /&gt;
**Floating Point Integers: Used to support decimal components. Go supports float32 and float64 to represent floating point numbers and complex32 and complex64 to represent complex numbers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var x int32 =4&lt;br /&gt;
var y float32 = 4.5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* String: String litersals can be created using either double quotes(“Hello”) or back ticks(`Hello`). Strings have several operations associated them, for example one can find the length of the string or get a character at a specific index in a string.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
	fmt.Println(len(“Hello”)) // output: 5&lt;br /&gt;
	fmt.Println(“Hello”[1]) // output: 1&lt;br /&gt;
	fmt.Println(“Hello “+”Tom”) //output: Hello Tom&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Boolean: A 1 bit value is used to represent true or false.&lt;br /&gt;
&lt;br /&gt;
==Variables and Constants==&lt;br /&gt;
*Variabes in Go are indicated using the var keyword. Example: var x string=”hello” . They can also be shorthanded as x:=”hello” .&lt;br /&gt;
*The variable names should begin with a letter and can contain letters, digits or underscore character.&lt;br /&gt;
*The scope of the variable is the block in which it is defined and an attempt to access it outside the block would result in an error on running the program.&lt;br /&gt;
*Go provides support for constants (i.e. variables whose value can not be changed), using the const keyword. Example: const temp string = “Hello”&lt;br /&gt;
*In Go one can define multiple variables(or constants) using the following syntax:&lt;br /&gt;
    var(&lt;br /&gt;
         t1 =1&lt;br /&gt;
         t2=2&lt;br /&gt;
         t3=3&lt;br /&gt;
        t4=4&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Control Structures==&lt;br /&gt;
*For: It is used for repeating a list of statement(s) multiple times. The example below is used for calculating sum of numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    i := 1&lt;br /&gt;
    sum := 0&lt;br /&gt;
&lt;br /&gt;
    for i &amp;lt;= 10 {&lt;br /&gt;
        sum = sum + i&lt;br /&gt;
        i = i + 1&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    fmt.Println(“Sum:” + sum)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the example above i is a loop counter variable and is used to ensure that sum of numbers from 1 to 10 is computed. It indicates the number of times the statements inside the for loop is to be executed. The statement following the keyword for should evaluate to either true or false. If it is evaluated to true the body of for is executed, else we come out of the for loop.&lt;br /&gt;
&lt;br /&gt;
*If: Used to execute a block of statement(s) based on the evaluation of an expression to either true or false. It can also have an else associated with it.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    if i % 2 == 0 {&lt;br /&gt;
        fmt.Println(i + ” is divisble by 2”)&lt;br /&gt;
    } else {&lt;br /&gt;
        fmt.Println(i + “is not divisible by 2”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Switch: The value of the expression following switch is evaluated and is compared against the different cases. Based on the matching case, the block following that case is executed. Switch also has a default case in situations when none of the cases are matching.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    // if op ==1 then so a+b&lt;br /&gt;
    // if op == 2 then do a-b&lt;br /&gt;
    // if op == 3 then do a*b&lt;br /&gt;
    // if op ==4 then do a/b&lt;br /&gt;
    // default print, invalid operator&lt;br /&gt;
&lt;br /&gt;
    op:= 1&lt;br /&gt;
    a=6&lt;br /&gt;
    b=7&lt;br /&gt;
    switch(op) {&lt;br /&gt;
        case 1: fmt.Println(a+b)&lt;br /&gt;
        case 2: fmt.Println(a-b)&lt;br /&gt;
        case 3: fmt.Println(a*b)&lt;br /&gt;
        case 4: fmt.Println(a/b)&lt;br /&gt;
        default: fmt.Println(“Invalid Operator”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Arrays, Slices and Maps==&lt;br /&gt;
&lt;br /&gt;
*Arrays: Numbered sequence of elements starting with index zero and each of the elements having a fixed length. The example below illustrates various operations performed on arrays in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
    var x[10] int&lt;br /&gt;
    x[99]=100&lt;br /&gt;
    fmt.Println(x)  //[0 0 ….. 0 100]&lt;br /&gt;
    fmt.Println(len(x)) //100&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Slices: &lt;br /&gt;
** It is a segment of an array.&lt;br /&gt;
** They have a length and are indexable.&lt;br /&gt;
**In case of a slice the size does not have to specified in the square bracket.&lt;br /&gt;
**Slices support two in-build functions: copy and append.&lt;br /&gt;
**The program below illustrates the different ways to create slices and use of copy and append.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    arr := [10] int {1,2,3,4,5,6,7,8,9,10}&lt;br /&gt;
    x := make([]int,10) // creates a slice [1...10]&lt;br /&gt;
    y := make([]int,10,10) //creates a slice [1...10]&lt;br /&gt;
    z := arr[0:10] //creates a slice [1...10]&lt;br /&gt;
    s1 := []int{1,2,3,4,5}&lt;br /&gt;
    s2 := append(s1, 6, 7)&lt;br /&gt;
    fmt.Println(s1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(s2) // [1,2,3,4,5,6,7]&lt;br /&gt;
    p1 := [] int{1,2,3,4,5}&lt;br /&gt;
    p2 :=make([]int, 4)&lt;br /&gt;
    copy(p2,p1)&lt;br /&gt;
    fmt.Println(p1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(p2)// [1,2,3,4]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Maps:&lt;br /&gt;
**A map is an unordered collection of key value pairs.&lt;br /&gt;
**Syntax: var x map[int] string , where int is the type of the key and string is the type of the value.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
    x := make(map[int]string)&lt;br /&gt;
    x[1] = one&lt;br /&gt;
    x[2] = two&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
&lt;br /&gt;
*In Go functions can take multiple inputs and return multiple outputs.&lt;br /&gt;
*Go supports a special kind of function called variadic function.&lt;br /&gt;
*Closure is the means by which functions can be created inside other function in Go.&lt;br /&gt;
*Go supports recursive functions.&lt;br /&gt;
*The example below the different types of function in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    display(“Hello World”)&lt;br /&gt;
    sum :=calculateSum(10,20)&lt;br /&gt;
    v1,v2=multipleValues()&lt;br /&gt;
    p=product(5,10,20)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function without return type&lt;br /&gt;
func display( s string) {&lt;br /&gt;
    fmt.Println(s)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns a single value&lt;br /&gt;
func calculateSum(a int, b int) int {&lt;br /&gt;
    c: = a + b&lt;br /&gt;
    return c&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns multiple values&lt;br /&gt;
func multipleValues(int, int) {&lt;br /&gt;
    return 1, 2&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Variadic function&lt;br /&gt;
func product(args ...int) int {&lt;br /&gt;
    p := 1&lt;br /&gt;
   for _, i := range args {&lt;br /&gt;
        p *= i&lt;br /&gt;
   }&lt;br /&gt;
   return p&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pointers==&lt;br /&gt;
It is used to reference a location in the memory where the value is stored rather than containing the value itself. Basic pointer operations in Go are illustrated in the example below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
//Different syntax for pointers&lt;br /&gt;
    &lt;br /&gt;
     ptr1 *int&lt;br /&gt;
     num :=10&lt;br /&gt;
     ptr1 = &amp;amp;num&lt;br /&gt;
     ptr2 := new(int)&lt;br /&gt;
     ptr2=&amp;amp;num&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Concurrency==&lt;br /&gt;
* Go ensures concurrency which allows sharing of state using communication mechanisms.&lt;br /&gt;
* Go provides support for multithreading and CPU parallelization.&lt;br /&gt;
* Go supports asynchrony i.e. allows operations like database and network I/O which are slow operations to occur in parallel along with other operations.&lt;br /&gt;
* A new lightweight process is created using go fund()&lt;br /&gt;
* Channel types are used for providing type safe and synchronized channels between different go routines.&lt;br /&gt;
&lt;br /&gt;
=Users of Go=&lt;br /&gt;
Apart from Google, which uses Go programming for some of its development, companies like [http://en.wikipedia.org/wiki/Dropbox_(service) Dropbox], [http://en.wikipedia.org/wiki/CloudFlare CloudFlare], [http://en.wikipedia.org/wiki/SoundCloud SoundCloud], The BBC, Novartis, Cloud Foundry also use Go programming.  &lt;br /&gt;
Dropbox server (running in the cloud) and desktop client software were primarily written in [http://en.wikipedia.org/wiki/Python_(programming_language) Python]. From mid-2013 Dropbox began migrating its backend infrastructure to Go.&lt;br /&gt;
Some of the open-source applications that are using Go programming are Docker, Flynn, PaaS, Juju, nsq, Doozer e.t.c .&amp;lt;ref name = &amp;quot;GoWIKI&amp;quot;&amp;gt;[http://en.wikipedia.org/wiki/Go_(programming_language), Wikipedia]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advantages=&lt;br /&gt;
 &lt;br /&gt;
*'''C Level Performance'''. golang is within a close margin of the performance level of C code (which is itself an extremely high performance language). It is certainly closer to the performance of native languages than other enterprise level languages such as Java, Scala, Erlang etc.&lt;br /&gt;
 &lt;br /&gt;
*'''Fast Compilation''' is one of the key advantages of Go language. The Golang compiler was designed to compile programs very quickly. Extremely large programs with massively high LOC counts compile seemingly instantly - after all, Golang was designed by Google to solve Google problems, and Google has big problems! At Google, code and CPU cores are both measured in the millions. Go provides a model for software construction that makes dependency analysis easy and avoids much of the overhead of C-style include files and libraries.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reduced compile time is a key improvement in the Go language&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      If A.go depends on B.go depends on C.go :&lt;br /&gt;
         Compile C.go, B.go then A.go normally (other languages)&lt;br /&gt;
         To compile A.go, compiler reads B.o not C.o (go)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At a large scale this should help in hugely speeding up&lt;br /&gt;
&lt;br /&gt;
Other advantages are      &lt;br /&gt;
* '''Concurrency Supported At Language Level'''. Concurrency is the ability to execute multiple computations simultaneously. In today's modern multicore and high-load computing environment, concurrency is a critical language feature, and one in which languages such as Java struggle immensely.&lt;br /&gt;
* By its design, Go proposes an approach for the construction of system software on '''multicore machines'''.&lt;br /&gt;
* Google have summed things up nicely with their motto: '''Don't communicate by sharing memory, share memory by communicating'''.Channels allow you to pass references to data structures between goroutines. If you consider this as passing around ownership of the data (the ability to read and write it), they become a powerful and expressive synchronization mechanism.  &lt;br /&gt;
* '''Go's type system has no hierarchy''', so no time is spent defining the relationships between types. Also, although Go has static types, the language attempts to make types feel lighter weight than in typical Object Oriented languages.&lt;br /&gt;
* '''Garbage Collection is much better'''. In C and C++, programmers spend a lot of time and energy on allocating and freeing memory. The designers of Go wanted to remove that complication, and ensure Go programmers could concentrate on more productive tasks. As such, they implemented garbage collection. As a developer, this is a very good thing. Sure, garbage collection comes with its own set of issues, but those are dealt with by the language implementer while the programmer is free to reap the other many benefits of Go.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
*Go is still an experimental language subject to change.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;&amp;gt;[http://stackoverflow.com/questions/2198529/what-are-the-advantages-and-disadvantages-of-go-programming-language stackoverflow]&amp;lt;/ref&amp;gt;&lt;br /&gt;
*Go's not very usable on Windows yet.&lt;br /&gt;
*The packages distributed with Go are pretty useful, but there are still some libraries you'll miss. Most notably a UI toolkit.&lt;br /&gt;
*There is no support for generics in Go, although there are many discussions around it.&lt;br /&gt;
*Confusing Semantics Of Exported Identifiers&amp;lt;ref name = &amp;quot;Limitations2&amp;quot;&amp;gt;&lt;br /&gt;
[https://functionwhatwhat.com/go’s-type-system-is-an-embarrassment functionwhatwhat ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=87487</id>
		<title>CSC/ECE 517 Fall 2014/ch1a 10 hu</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=87487"/>
		<updated>2014-09-20T01:20:56Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Concurrency */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Go''', also commonly referred to as '''golang''', is a compiled, concurrent, garbage-collected, statically typed language developed at [http://en.wikipedia.org/wiki/Google Google]. It was developed by [http://en.wikipedia.org/wiki/Robert_Griesemer Robert Griesemer], [http://en.wikipedia.org/wiki/Rob_Pike Rob Pike] and [http://en.wikipedia.org/wiki/Ken_Thompson Ken Thompson] in 2007. It was announced in November 2009 and is currently being used in many production systems at Google. It is an open source project. The syntax is loosely derived from that of [http://en.wikipedia.org/wiki/C_(programming_language) C programming language], adding [http://en.wikipedia.org/wiki/Garbage_collection_(computer_science) Garbage collection], type safety, some dynamic-typing capabilities. Additional built-in types such as variable-length arrays and key-value maps, and a large standard library are also supported. Different operating systems like Linux, Microsoft Windows, Mac OS X are suported by gc compiler of Go.&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
&lt;br /&gt;
Go programming started of as a research project by Robert Griesemer, Rob Pike and Ken Thompson. They felt that there was no new system focused programming language that has come up in the last decade till 2008, while there were other developments like increase in the size of libraries, dominance of networking , client server focus, multi-core CPUs.&amp;lt;ref name = &amp;quot;Background 1&amp;quot;&amp;gt;[https://www.youtube.com/watch?v=rKnDgT73v8s Go Language Introduction speech]&amp;lt;/ref&amp;gt; So they wanted to come up with a new systems focused programming language that would address the above issues.&amp;lt;ref name=&amp;quot;BG2&amp;quot;&amp;gt;[http://techcrunch.com/2009/11/10/google-go-language TechCrunch]&amp;lt;/ref&amp;gt; They started sketching the goals for a new language on the white board on September 21, 2007. Within a few days the goals had settled into a plan to do something and a fair idea of what it would be. Design continued part-time in parallel with unrelated work.&lt;br /&gt;
By January 2008, Ken had started work on a compiler with which to explore ideas; it generated C code as its output. By mid-year the language had become a full-time project and had settled enough to attempt a production compiler. In May 2008, [http://research.google.com/pubs/author37504.html Ian Taylor] independently started on a [http://en.wikipedia.org/wiki/GNU_Compiler_Collection GCC] front end for Go using the draft specification.  [http://russ.cox.usesthis.com/ Russ Cox] joined in late 2008 and helped move the language and libraries from prototype to reality.&lt;br /&gt;
Go became a public [http://en.wikipedia.org/wiki/Open_source open source project] on November 10, 2009. Many people from the community have contributed ideas, discussions, and code.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Compilers and Runtime support=&lt;br /&gt;
&lt;br /&gt;
There are two Go compiler implementations, [https://golang.org/cmd/gc Gc] (the 6g program and friends) and [http://blog.golang.org/gccgo-in-gcc-471 gccgo ]. Gc uses a different calling convention and linker. It can therefore only be linked with C programs using the same convention. Gccgo is a GCC front-end that can be linked with GCC-compiled C or C++ programs.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cgo program provides the mechanism for a “foreign function interface” to allow safe calling of C libraries from Go code. [http://en.wikipedia.org/wiki/SWIG SWIG] extends this capability to C++ libraries. &lt;br /&gt;
&lt;br /&gt;
Again due to bootstrapping issues, the run-time code is mostly in C (with a tiny bit of assembler) although Go is capable of implementing most of it now. Gccgo's run-time support uses glibc. Gc uses a custom library to keep the footprint under control; it is compiled with a version of the [http://plan9.bell-labs.com/sys/doc/compiler.html Plan 9 C compiler] that supports resizable stacks for goroutines. The gccgo compiler implements these on Linux only, using a technique called segmented stacks, supported by recent modifications to the gold linker.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find all resources needed to compile and run Go Language here http://go-lang.cat-v.org/&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
 &lt;br /&gt;
Programming today involves too much bookkeeping, repetition, and clerical work. As Dick Gabriel says, “Old programs read like quiet conversations between a well-spoken research worker and a well-studied mechanical colleague, not as a debate with a compiler. Who'd have guessed sophistication bought such noise?” The sophistication is worthwhile—no one wants to go back to the old languages—but can it be more quietly achieved?&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Go attempts to reduce the amount of typing in both senses of the word. Throughout its design, &lt;br /&gt;
*They have tried to reduce clutter and complexity. &lt;br /&gt;
*There are no forward declarations and no header files. everything is declared exactly once. &lt;br /&gt;
*Initialization is expressive, automatic, and easy to use. &lt;br /&gt;
*Syntax is clean and light on keywords. Stuttering (foo.Foo* myFoo = new(foo.Foo)) is reduced by simple type derivation using the := declare-and-initialize construct. &lt;br /&gt;
*And perhaps most radically, there is no type hierarchy. They don't have to announce their relationships.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
These simplifications allow Go to be expressive yet comprehensible without sacrificing, well, sophistication.&lt;br /&gt;
Another important principle is to keep the concepts orthogonal. Methods can be implemented for any type; structures represent data while interfaces represent abstraction; and so on. Orthogonality makes it easier to understand what happens when things combine.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Language Design=&lt;br /&gt;
&amp;lt;ref name = &amp;quot;GoLang Book&amp;quot;&amp;gt;[http://www.golang-book.com, GoLang Book]&amp;lt;/ref&amp;gt;&lt;br /&gt;
==Syntax==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 package main //line 1&lt;br /&gt;
&lt;br /&gt;
   import “fmt”  //line 2&lt;br /&gt;
&lt;br /&gt;
   func main() {  //line 3&lt;br /&gt;
&lt;br /&gt;
       fmt.Println(“Hello World”) //line 4&lt;br /&gt;
&lt;br /&gt;
   } //line 5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Line1 specifies package declaration. Package is used to organize and reuse code. Line 2 is used for including the package “fmt” which is used for formatting input and output. Line 3 to 5 defines the function main. main is the function which is called when a program is executed. Println function in fmt is used to display content to the console i.e in this example Hello World is displayed in the console on executing the program.&lt;br /&gt;
&lt;br /&gt;
==Code Conventions and Style==&lt;br /&gt;
&lt;br /&gt;
* Go fmt tool is used to automatically standardize indentation, spaces and surface-level code details. go vet and go link are perform checking automatically.&lt;br /&gt;
* Using tools and libraries provided in Go, there are standard approaches for API documentation(go doc), testing(go test), building(go build) and package management(go get).&lt;br /&gt;
* Syntax prevents any kind of cyclic dependencies.&lt;br /&gt;
* Unused variables and imports are not allowed.&lt;br /&gt;
* Elimination of functional programming constructs (such as map and try/finally in C++) ensure a concrete and explicit programming style.&lt;br /&gt;
&lt;br /&gt;
==Types==&lt;br /&gt;
&lt;br /&gt;
* Numbers are represented in Go as either Integers or Floating point numbers.&lt;br /&gt;
**Integers: Used to represent numbers without a decimal component. Different integers supported by Go are: uint8, uint16, uint32, uint64, int8, int16, int32, int64. Uint is used for unsigned integers and int for signed. 8,16, 32, 64 indicate the number of bits each type would use.&lt;br /&gt;
**Floating Point Integers: Used to support decimal components. Go supports float32 and float64 to represent floating point numbers and complex32 and complex64 to represent complex numbers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var x int32 =4&lt;br /&gt;
var y float32 = 4.5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* String: String litersals can be created using either double quotes(“Hello”) or back ticks(`Hello`). Strings have several operations associated them, for example one can find the length of the string or get a character at a specific index in a string.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
	fmt.Println(len(“Hello”)) // output: 5&lt;br /&gt;
	fmt.Println(“Hello”[1]) // output: 1&lt;br /&gt;
	fmt.Println(“Hello “+”Tom”) //output: Hello Tom&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Boolean: A 1 bit value is used to represent true or false.&lt;br /&gt;
&lt;br /&gt;
==Variables and Constants==&lt;br /&gt;
*Variabes in Go are indicated using the var keyword. Example: var x string=”hello” . They can also be shorthanded as x:=”hello” .&lt;br /&gt;
*The variable names should begin with a letter and can contain letters, digits or underscore character.&lt;br /&gt;
*The scope of the variable is the block in which it is defined and an attempt to access it outside the block would result in an error on running the program.&lt;br /&gt;
*Go provides support for constants (i.e. variables whose value can not be changed), using the const keyword. Example: const temp string = “Hello”&lt;br /&gt;
*In Go one can define multiple variables(or constants) using the following syntax:&lt;br /&gt;
    var(&lt;br /&gt;
         t1 =1&lt;br /&gt;
         t2=2&lt;br /&gt;
         t3=3&lt;br /&gt;
        t4=4&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Control Structures==&lt;br /&gt;
*For: It is used for repeating a list of statement(s) multiple times. The example below is used for calculating sum of numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    i := 1&lt;br /&gt;
    sum := 0&lt;br /&gt;
&lt;br /&gt;
    for i &amp;lt;= 10 {&lt;br /&gt;
        sum = sum + i&lt;br /&gt;
        i = i + 1&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    fmt.Println(“Sum:” + sum)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the example above i is a loop counter variable and is used to ensure that sum of numbers from 1 to 10 is computed. It indicates the number of times the statements inside the for loop is to be executed. The statement following the keyword for should evaluate to either true or false. If it is evaluated to true the body of for is executed, else we come out of the for loop.&lt;br /&gt;
&lt;br /&gt;
*If: Used to execute a block of statement(s) based on the evaluation of an expression to either true or false. It can also have an else associated with it.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    if i % 2 == 0 {&lt;br /&gt;
        fmt.Println(i + ” is divisble by 2”)&lt;br /&gt;
    } else {&lt;br /&gt;
        fmt.Println(i + “is not divisible by 2”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Switch: The value of the expression following switch is evaluated and is compared against the different cases. Based on the matching case, the block following that case is executed. Switch also has a default case in situations when none of the cases are matching.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    // if op ==1 then so a+b&lt;br /&gt;
    // if op == 2 then do a-b&lt;br /&gt;
    // if op == 3 then do a*b&lt;br /&gt;
    // if op ==4 then do a/b&lt;br /&gt;
    // default print, invalid operator&lt;br /&gt;
&lt;br /&gt;
    op:= 1&lt;br /&gt;
    a=6&lt;br /&gt;
    b=7&lt;br /&gt;
    switch(op) {&lt;br /&gt;
        case 1: fmt.Println(a+b)&lt;br /&gt;
        case 2: fmt.Println(a-b)&lt;br /&gt;
        case 3: fmt.Println(a*b)&lt;br /&gt;
        case 4: fmt.Println(a/b)&lt;br /&gt;
        default: fmt.Println(“Invalid Operator”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Arrays, Slices and Maps==&lt;br /&gt;
&lt;br /&gt;
*Arrays: Numbered sequence of elements starting with index zero and each of the elements having a fixed length. The example below illustrates various operations performed on arrays in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
    var x[10] int&lt;br /&gt;
    x[99]=100&lt;br /&gt;
    fmt.Println(x)  //[0 0 ….. 0 100]&lt;br /&gt;
    fmt.Println(len(x)) //100&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Slices: &lt;br /&gt;
** It is a segment of an array.&lt;br /&gt;
** They have a length and are indexable.&lt;br /&gt;
**In case of a slice the size does not have to specified in the square bracket.&lt;br /&gt;
**Slices support two in-build functions: copy and append.&lt;br /&gt;
**The program below illustrates the different ways to create slices and use of copy and append.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    arr := [10] int {1,2,3,4,5,6,7,8,9,10}&lt;br /&gt;
    x := make([]int,10) // creates a slice [1...10]&lt;br /&gt;
    y := make([]int,10,10) //creates a slice [1...10]&lt;br /&gt;
    z := arr[0:10] //creates a slice [1...10]&lt;br /&gt;
    s1 := []int{1,2,3,4,5}&lt;br /&gt;
    s2 := append(s1, 6, 7)&lt;br /&gt;
    fmt.Println(s1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(s2) // [1,2,3,4,5,6,7]&lt;br /&gt;
    p1 := [] int{1,2,3,4,5}&lt;br /&gt;
    p2 :=make([]int, 4)&lt;br /&gt;
    copy(p2,p1)&lt;br /&gt;
    fmt.Println(p1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(p2)// [1,2,3,4]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Maps:&lt;br /&gt;
**A map is an unordered collection of key value pairs.&lt;br /&gt;
**Syntax: var x map[int] string , where int is the type of the key and string is the type of the value.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
    x := make(map[int]string)&lt;br /&gt;
    x[1] = one&lt;br /&gt;
    x[2] = two&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
&lt;br /&gt;
*In Go functions can take multiple inputs and return multiple outputs.&lt;br /&gt;
*Go supports a special kind of function called variadic function.&lt;br /&gt;
*Closure is the means by which functions can be created inside other function in Go.&lt;br /&gt;
*Go supports recursive functions.&lt;br /&gt;
*The example below the different types of function in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    display(“Hello World”)&lt;br /&gt;
    sum :=calculateSum(10,20)&lt;br /&gt;
    v1,v2=multipleValues()&lt;br /&gt;
    p=product(5,10,20)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function without return type&lt;br /&gt;
func display( s string) {&lt;br /&gt;
    fmt.Println(s)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns a single value&lt;br /&gt;
func calculateSum(a int, b int) int {&lt;br /&gt;
    c: = a + b&lt;br /&gt;
    return c&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns multiple values&lt;br /&gt;
func multipleValues(int, int) {&lt;br /&gt;
    return 1, 2&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Variadic function&lt;br /&gt;
func product(args ...int) int {&lt;br /&gt;
    p := 1&lt;br /&gt;
   for _, i := range args {&lt;br /&gt;
        p *= i&lt;br /&gt;
   }&lt;br /&gt;
   return p&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pointers==&lt;br /&gt;
It is used to reference a location in the memory where the value is stored rather than containing the value itself. Basic pointer operations in Go are illustrated in the example below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
//Different syntax for pointers&lt;br /&gt;
    &lt;br /&gt;
     ptr1 *int&lt;br /&gt;
     num :=10&lt;br /&gt;
     ptr1 = &amp;amp;num&lt;br /&gt;
     ptr2 := new(int)&lt;br /&gt;
     ptr2=&amp;amp;num&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Concurrency==&lt;br /&gt;
* Go ensures concurrency which allows sharing of state using communication mechanisms.&lt;br /&gt;
* Go provides support for multithreading and CPU parallelization.&lt;br /&gt;
* Go supports asynchrony i.e. allows operations like database and network I/O which are slow operations to occur in parallel along with other operations.&lt;br /&gt;
* A new lightweight process is created using go fund()&lt;br /&gt;
* Channel types are used for providing type safe and synchronized channels between different go routines.&lt;br /&gt;
&lt;br /&gt;
=Users of Go=&lt;br /&gt;
Apart from Google, which uses Go programming for some of its development, companies like [http://en.wikipedia.org/wiki/Dropbox_(service) Dropbox], [http://en.wikipedia.org/wiki/CloudFlare CloudFlare], [http://en.wikipedia.org/wiki/SoundCloud SoundCloud], The BBC, Novartis, Cloud Foundry also use Go programming.  &lt;br /&gt;
Dropbox server (running in the cloud) and desktop client software were primarily written in [http://en.wikipedia.org/wiki/Python_(programming_language) Python]. From mid-2013 Dropbox began migrating its backend infrastructure to Go.&lt;br /&gt;
Some of the open-source applications that are using Go programming are Docker, Flynn, PaaS, Juju, nsq, Doozer e.t.c .&amp;lt;ref name = &amp;quot;GoWIKI&amp;quot;&amp;gt;[http://en.wikipedia.org/wiki/Go_(programming_language), Wikipedia]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advantages=&lt;br /&gt;
 &lt;br /&gt;
*'''C Level Performance'''. golang is within a close margin of the performance level of C code (which is itself an extremely high performance language). It is certainly closer to the performance of native languages than other enterprise level languages such as Java, Scala, Erlang etc.&lt;br /&gt;
 &lt;br /&gt;
*'''Fast Compilation''' is one of the key advantages of Go language. The Golang compiler was designed to compile programs very quickly. Extremely large programs with massively high LOC counts compile seemingly instantly - after all, Golang was designed by Google to solve Google problems, and Google has big problems! At Google, code and CPU cores are both measured in the millions. Go provides a model for software construction that makes dependency analysis easy and avoids much of the overhead of C-style include files and libraries.&lt;br /&gt;
&lt;br /&gt;
Reduced compile time is a key improvement in the Go language&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      If A.go depends on B.go depends on C.go :&lt;br /&gt;
         Compile C.go, B.go then A.go normally (other languages)&lt;br /&gt;
         To compile A.go, compiler reads B.o not C.o (go)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At a large scale this should help in hugely speeding up&lt;br /&gt;
&lt;br /&gt;
Other advantages are      &lt;br /&gt;
* '''Concurrency Supported At Language Level'''. Concurrency is the ability to execute multiple computations simultaneously. In today's modern multicore and high-load computing environment, concurrency is a critical language feature, and one in which languages such as Java struggle immensely.&lt;br /&gt;
* By its design, Go proposes an approach for the construction of system software on '''multicore machines'''.&lt;br /&gt;
* Google have summed things up nicely with their motto: '''Don't communicate by sharing memory, share memory by communicating'''.Channels allow you to pass references to data structures between goroutines. If you consider this as passing around ownership of the data (the ability to read and write it), they become a powerful and expressive synchronization mechanism.  &lt;br /&gt;
* '''Go's type system has no hierarchy''', so no time is spent defining the relationships between types. Also, although Go has static types, the language attempts to make types feel lighter weight than in typical Object Oriented languages.&lt;br /&gt;
* '''Garbage Collection is much better'''. In C and C++, programmers spend a lot of time and energy on allocating and freeing memory. The designers of Go wanted to remove that complication, and ensure Go programmers could concentrate on more productive tasks. As such, they implemented garbage collection. As a developer, this is a very good thing. Sure, garbage collection comes with its own set of issues, but those are dealt with by the language implementer while the programmer is free to reap the other many benefits of Go.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
*Go is still an experimental language subject to change.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;&amp;gt;[http://stackoverflow.com/questions/2198529/what-are-the-advantages-and-disadvantages-of-go-programming-language stackoverflow]&amp;lt;/ref&amp;gt;&lt;br /&gt;
*Go's not very usable on Windows yet.&lt;br /&gt;
*The packages distributed with Go are pretty useful, but there are still some libraries you'll miss. Most notably a UI toolkit.&lt;br /&gt;
*There is no support for generics in Go, although there are many discussions around it.&lt;br /&gt;
*Confusing Semantics Of Exported Identifiers&amp;lt;ref name = &amp;quot;Limitations2&amp;quot;&amp;gt;&lt;br /&gt;
[https://functionwhatwhat.com/go’s-type-system-is-an-embarrassment functionwhatwhat ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=87468</id>
		<title>CSC/ECE 517 Fall 2014/ch1a 10 hu</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=87468"/>
		<updated>2014-09-20T01:14:18Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Concurrency */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Go''', also commonly referred to as '''golang''', is a compiled, concurrent, garbage-collected, statically typed language developed at [http://en.wikipedia.org/wiki/Google Google]. It was developed by [http://en.wikipedia.org/wiki/Robert_Griesemer Robert Griesemer], [http://en.wikipedia.org/wiki/Rob_Pike Rob Pike] and [http://en.wikipedia.org/wiki/Ken_Thompson Ken Thompson] in 2007. It was announced in November 2009 and is currently being used in many production systems at Google. It is an open source project. The syntax is loosely derived from that of [http://en.wikipedia.org/wiki/C_(programming_language) C programming language], adding [http://en.wikipedia.org/wiki/Garbage_collection_(computer_science) Garbage collection], type safety, some dynamic-typing capabilities. Additional built-in types such as variable-length arrays and key-value maps, and a large standard library are also supported. Different operating systems like Linux, Microsoft Windows, Mac OS X are suported by gc compiler of Go.&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
&lt;br /&gt;
Go programming started of as a research project by Robert Griesemer, Rob Pike and Ken Thompson. They felt that there was no new system focused programming language that has come up in the last decade till 2008, while there were other developments like increase in the size of libraries, dominance of networking , client server focus, multi-core CPUs.&amp;lt;ref name = &amp;quot;Background 1&amp;quot;&amp;gt;[https://www.youtube.com/watch?v=rKnDgT73v8s Go Language Introduction speech]&amp;lt;/ref&amp;gt; So they wanted to come up with a new systems focused programming language that would address the above issues.&amp;lt;ref name=&amp;quot;BG2&amp;quot;&amp;gt;[http://techcrunch.com/2009/11/10/google-go-language TechCrunch]&amp;lt;/ref&amp;gt; They started sketching the goals for a new language on the white board on September 21, 2007. Within a few days the goals had settled into a plan to do something and a fair idea of what it would be. Design continued part-time in parallel with unrelated work.&lt;br /&gt;
By January 2008, Ken had started work on a compiler with which to explore ideas; it generated C code as its output. By mid-year the language had become a full-time project and had settled enough to attempt a production compiler. In May 2008, [http://research.google.com/pubs/author37504.html Ian Taylor] independently started on a [http://en.wikipedia.org/wiki/GNU_Compiler_Collection GCC] front end for Go using the draft specification.  [http://russ.cox.usesthis.com/ Russ Cox] joined in late 2008 and helped move the language and libraries from prototype to reality.&lt;br /&gt;
Go became a public [http://en.wikipedia.org/wiki/Open_source open source project] on November 10, 2009. Many people from the community have contributed ideas, discussions, and code.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Compilers and Runtime support=&lt;br /&gt;
&lt;br /&gt;
There are two Go compiler implementations, [https://golang.org/cmd/gc Gc] (the 6g program and friends) and [http://blog.golang.org/gccgo-in-gcc-471 gccgo ]. Gc uses a different calling convention and linker. It can therefore only be linked with C programs using the same convention. Gccgo is a GCC front-end that can be linked with GCC-compiled C or C++ programs.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cgo program provides the mechanism for a “foreign function interface” to allow safe calling of C libraries from Go code. [http://en.wikipedia.org/wiki/SWIG SWIG] extends this capability to C++ libraries. &lt;br /&gt;
&lt;br /&gt;
Again due to bootstrapping issues, the run-time code is mostly in C (with a tiny bit of assembler) although Go is capable of implementing most of it now. Gccgo's run-time support uses glibc. Gc uses a custom library to keep the footprint under control; it is compiled with a version of the [http://plan9.bell-labs.com/sys/doc/compiler.html Plan 9 C compiler] that supports resizable stacks for goroutines. The gccgo compiler implements these on Linux only, using a technique called segmented stacks, supported by recent modifications to the gold linker.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find all resources needed to compile and run Go Language here http://go-lang.cat-v.org/&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
 &lt;br /&gt;
Programming today involves too much bookkeeping, repetition, and clerical work. As Dick Gabriel says, “Old programs read like quiet conversations between a well-spoken research worker and a well-studied mechanical colleague, not as a debate with a compiler. Who'd have guessed sophistication bought such noise?” The sophistication is worthwhile—no one wants to go back to the old languages—but can it be more quietly achieved?&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Go attempts to reduce the amount of typing in both senses of the word. Throughout its design, &lt;br /&gt;
*They have tried to reduce clutter and complexity. &lt;br /&gt;
*There are no forward declarations and no header files. everything is declared exactly once. &lt;br /&gt;
*Initialization is expressive, automatic, and easy to use. &lt;br /&gt;
*Syntax is clean and light on keywords. Stuttering (foo.Foo* myFoo = new(foo.Foo)) is reduced by simple type derivation using the := declare-and-initialize construct. &lt;br /&gt;
*And perhaps most radically, there is no type hierarchy. They don't have to announce their relationships.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
These simplifications allow Go to be expressive yet comprehensible without sacrificing, well, sophistication.&lt;br /&gt;
Another important principle is to keep the concepts orthogonal. Methods can be implemented for any type; structures represent data while interfaces represent abstraction; and so on. Orthogonality makes it easier to understand what happens when things combine.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Language Design=&lt;br /&gt;
==Syntax==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 package main //line 1&lt;br /&gt;
&lt;br /&gt;
   import “fmt”  //line 2&lt;br /&gt;
&lt;br /&gt;
   func main() {  //line 3&lt;br /&gt;
&lt;br /&gt;
       fmt.Println(“Hello World”) //line 4&lt;br /&gt;
&lt;br /&gt;
   } //line 5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Line1 specifies package declaration. Package is used to organize and reuse code. Line 2 is used for including the package “fmt” which is used for formatting input and output. Line 3 to 5 defines the function main. main is the function which is called when a program is executed. Println function in fmt is used to display content to the console i.e in this example Hello World is displayed in the console on executing the program.&lt;br /&gt;
&lt;br /&gt;
==Code Conventions and Style==&lt;br /&gt;
&lt;br /&gt;
* Go fmt tool is used to automatically standardize indentation, spaces and surface-level code details. go vet and go link are perform checking automatically.&lt;br /&gt;
* Using tools and libraries provided in Go, there are standard approaches for API documentation(go doc), testing(go test), building(go build) and package management(go get).&lt;br /&gt;
* Syntax prevents any kind of cyclic dependencies.&lt;br /&gt;
* Unused variables and imports are not allowed.&lt;br /&gt;
* Elimination of functional programming constructs (such as map and try/finally in C++) ensure a concrete and explicit programming style.&lt;br /&gt;
&lt;br /&gt;
==Types==&lt;br /&gt;
&lt;br /&gt;
* Numbers are represented in Go as either Integers or Floating point numbers.&lt;br /&gt;
**Integers: Used to represent numbers without a decimal component. Different integers supported by Go are: uint8, uint16, uint32, uint64, int8, int16, int32, int64. Uint is used for unsigned integers and int for signed. 8,16, 32, 64 indicate the number of bits each type would use.&lt;br /&gt;
**Floating Point Integers: Used to support decimal components. Go supports float32 and float64 to represent floating point numbers and complex32 and complex64 to represent complex numbers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var x int32 =4&lt;br /&gt;
var y float32 = 4.5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* String: String litersals can be created using either double quotes(“Hello”) or back ticks(`Hello`). Strings have several operations associated them, for example one can find the length of the string or get a character at a specific index in a string.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
	fmt.Println(len(“Hello”)) // output: 5&lt;br /&gt;
	fmt.Println(“Hello”[1]) // output: 1&lt;br /&gt;
	fmt.Println(“Hello “+”Tom”) //output: Hello Tom&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Boolean: A 1 bit value is used to represent true or false.&lt;br /&gt;
&lt;br /&gt;
==Variables and Constants==&lt;br /&gt;
*Variabes in Go are indicated using the var keyword. Example: var x string=”hello” . They can also be shorthanded as x:=”hello” .&lt;br /&gt;
*The variable names should begin with a letter and can contain letters, digits or underscore character.&lt;br /&gt;
*The scope of the variable is the block in which it is defined and an attempt to access it outside the block would result in an error on running the program.&lt;br /&gt;
*Go provides support for constants (i.e. variables whose value can not be changed), using the const keyword. Example: const temp string = “Hello”&lt;br /&gt;
*In Go one can define multiple variables(or constants) using the following syntax:&lt;br /&gt;
    var(&lt;br /&gt;
         t1 =1&lt;br /&gt;
         t2=2&lt;br /&gt;
         t3=3&lt;br /&gt;
        t4=4&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Control Structures==&lt;br /&gt;
*For: It is used for repeating a list of statement(s) multiple times. The example below is used for calculating sum of numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    i := 1&lt;br /&gt;
    sum := 0&lt;br /&gt;
&lt;br /&gt;
    for i &amp;lt;= 10 {&lt;br /&gt;
        sum = sum + i&lt;br /&gt;
        i = i + 1&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    fmt.Println(“Sum:” + sum)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the example above i is a loop counter variable and is used to ensure that sum of numbers from 1 to 10 is computed. It indicates the number of times the statements inside the for loop is to be executed. The statement following the keyword for should evaluate to either true or false. If it is evaluated to true the body of for is executed, else we come out of the for loop.&lt;br /&gt;
&lt;br /&gt;
*If: Used to execute a block of statement(s) based on the evaluation of an expression to either true or false. It can also have an else associated with it.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    if i % 2 == 0 {&lt;br /&gt;
        fmt.Println(i + ” is divisble by 2”)&lt;br /&gt;
    } else {&lt;br /&gt;
        fmt.Println(i + “is not divisible by 2”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Switch: The value of the expression following switch is evaluated and is compared against the different cases. Based on the matching case, the block following that case is executed. Switch also has a default case in situations when none of the cases are matching.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    // if op ==1 then so a+b&lt;br /&gt;
    // if op == 2 then do a-b&lt;br /&gt;
    // if op == 3 then do a*b&lt;br /&gt;
    // if op ==4 then do a/b&lt;br /&gt;
    // default print, invalid operator&lt;br /&gt;
&lt;br /&gt;
    op:= 1&lt;br /&gt;
    a=6&lt;br /&gt;
    b=7&lt;br /&gt;
    switch(op) {&lt;br /&gt;
        case 1: fmt.Println(a+b)&lt;br /&gt;
        case 2: fmt.Println(a-b)&lt;br /&gt;
        case 3: fmt.Println(a*b)&lt;br /&gt;
        case 4: fmt.Println(a/b)&lt;br /&gt;
        default: fmt.Println(“Invalid Operator”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Arrays, Slices and Maps==&lt;br /&gt;
&lt;br /&gt;
*Arrays: Numbered sequence of elements starting with index zero and each of the elements having a fixed length. The example below illustrates various operations performed on arrays in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
    var x[10] int&lt;br /&gt;
    x[99]=100&lt;br /&gt;
    fmt.Println(x)  //[0 0 ….. 0 100]&lt;br /&gt;
    fmt.Println(len(x)) //100&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Slices: &lt;br /&gt;
** It is a segment of an array.&lt;br /&gt;
** They have a length and are indexable.&lt;br /&gt;
**In case of a slice the size does not have to specified in the square bracket.&lt;br /&gt;
**Slices support two in-build functions: copy and append.&lt;br /&gt;
**The program below illustrates the different ways to create slices and use of copy and append.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    arr := [10] int {1,2,3,4,5,6,7,8,9,10}&lt;br /&gt;
    x := make([]int,10) // creates a slice [1...10]&lt;br /&gt;
    y := make([]int,10,10) //creates a slice [1...10]&lt;br /&gt;
    z := arr[0:10] //creates a slice [1...10]&lt;br /&gt;
    s1 := []int{1,2,3,4,5}&lt;br /&gt;
    s2 := append(s1, 6, 7)&lt;br /&gt;
    fmt.Println(s1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(s2) // [1,2,3,4,5,6,7]&lt;br /&gt;
    p1 := [] int{1,2,3,4,5}&lt;br /&gt;
    p2 :=make([]int, 4)&lt;br /&gt;
    copy(p2,p1)&lt;br /&gt;
    fmt.Println(p1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(p2)// [1,2,3,4]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Maps:&lt;br /&gt;
**A map is an unordered collection of key value pairs.&lt;br /&gt;
**Syntax: var x map[int] string , where int is the type of the key and string is the type of the value.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
    x := make(map[int]string)&lt;br /&gt;
    x[1] = one&lt;br /&gt;
    x[2] = two&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
&lt;br /&gt;
*In Go functions can take multiple inputs and return multiple outputs.&lt;br /&gt;
*Go supports a special kind of function called variadic function.&lt;br /&gt;
*Closure is the means by which functions can be created inside other function in Go.&lt;br /&gt;
*Go supports recursive functions.&lt;br /&gt;
*The example below the different types of function in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    display(“Hello World”)&lt;br /&gt;
    sum :=calculateSum(10,20)&lt;br /&gt;
    v1,v2=multipleValues()&lt;br /&gt;
    p=product(5,10,20)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function without return type&lt;br /&gt;
func display( s string) {&lt;br /&gt;
    fmt.Println(s)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns a single value&lt;br /&gt;
func calculateSum(a int, b int) int {&lt;br /&gt;
    c: = a + b&lt;br /&gt;
    return c&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns multiple values&lt;br /&gt;
func multipleValues(int, int) {&lt;br /&gt;
    return 1, 2&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Variadic function&lt;br /&gt;
func product(args ...int) int {&lt;br /&gt;
    p := 1&lt;br /&gt;
   for _, i := range args {&lt;br /&gt;
        p *= i&lt;br /&gt;
   }&lt;br /&gt;
   return p&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pointers==&lt;br /&gt;
It is used to reference a location in the memory where the value is stored rather than containing the value itself. Basic pointer operations in Go are illustrated in the example below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
//Different syntax for pointers&lt;br /&gt;
    &lt;br /&gt;
     ptr1 *int&lt;br /&gt;
     num :=10&lt;br /&gt;
     ptr1 = &amp;amp;num&lt;br /&gt;
     ptr2 := new(int)&lt;br /&gt;
     ptr2=&amp;amp;num&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Concurrency==&lt;br /&gt;
* Go ensures concurrency which allows sharing of state using communication mechanisms.&lt;br /&gt;
* Go provides support for multithreading and CPU parallelization.&lt;br /&gt;
* Go supports asynchrony i.e. allows operations like database and network I/O which are slow operations to occur in parallel along with other operations.&lt;br /&gt;
* A new lightweight process is created using go fund()&lt;br /&gt;
* Channel types are used for providing&lt;br /&gt;
&lt;br /&gt;
=Users of Go=&lt;br /&gt;
Apart from Google, which uses Go programming for some of its development, companies like [http://en.wikipedia.org/wiki/Dropbox_(service) Dropbox], [http://en.wikipedia.org/wiki/CloudFlare CloudFlare], [http://en.wikipedia.org/wiki/SoundCloud SoundCloud], The BBC, Novartis, Cloud Foundry also use Go programming.  &lt;br /&gt;
Dropbox server (running in the cloud) and desktop client software were primarily written in [http://en.wikipedia.org/wiki/Python_(programming_language) Python]. From mid-2013 Dropbox began migrating its backend infrastructure to Go.&lt;br /&gt;
Some of the open-source applications that are using Go programming are Docker, Flynn, PaaS, Juju, nsq, Doozer e.t.c .&amp;lt;ref name = &amp;quot;GoWIKI&amp;quot;&amp;gt;[http://en.wikipedia.org/wiki/Go_(programming_language), Wikipedia]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advantages=&lt;br /&gt;
 &lt;br /&gt;
*'''C Level Performance'''. golang is within a close margin of the performance level of C code (which is itself an extremely high performance language). It is certainly closer to the performance of native languages than other enterprise level languages such as Java, Scala, Erlang etc.&lt;br /&gt;
 &lt;br /&gt;
*'''Fast Compilation''' is one of the key advantages of Go language. The Golang compiler was designed to compile programs very quickly. Extremely large programs with massively high LOC counts compile seemingly instantly - after all, Golang was designed by Google to solve Google problems, and Google has big problems! At Google, code and CPU cores are both measured in the millions. Go provides a model for software construction that makes dependency analysis easy and avoids much of the overhead of C-style include files and libraries.&lt;br /&gt;
&lt;br /&gt;
Reduced compile time is a key improvement in the Go language&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      If A.go depends on B.go depends on C.go :&lt;br /&gt;
         Compile C.go, B.go then A.go normally (other languages)&lt;br /&gt;
         To compile A.go, compiler reads B.o not C.o (go)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At a large scale this should help in hugely speeding up&lt;br /&gt;
&lt;br /&gt;
Other advantages are      &lt;br /&gt;
* '''Concurrency Supported At Language Level'''. Concurrency is the ability to execute multiple computations simultaneously. In today's modern multicore and high-load computing environment, concurrency is a critical language feature, and one in which languages such as Java struggle immensely.&lt;br /&gt;
* By its design, Go proposes an approach for the construction of system software on '''multicore machines'''.&lt;br /&gt;
* Google have summed things up nicely with their motto: '''Don't communicate by sharing memory, share memory by communicating'''.Channels allow you to pass references to data structures between goroutines. If you consider this as passing around ownership of the data (the ability to read and write it), they become a powerful and expressive synchronization mechanism.  &lt;br /&gt;
* '''Go's type system has no hierarchy''', so no time is spent defining the relationships between types. Also, although Go has static types, the language attempts to make types feel lighter weight than in typical Object Oriented languages.&lt;br /&gt;
* '''Garbage Collection is much better'''. In C and C++, programmers spend a lot of time and energy on allocating and freeing memory. The designers of Go wanted to remove that complication, and ensure Go programmers could concentrate on more productive tasks. As such, they implemented garbage collection. As a developer, this is a very good thing. Sure, garbage collection comes with its own set of issues, but those are dealt with by the language implementer while the programmer is free to reap the other many benefits of Go.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
*Go is still an experimental language subject to change.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;&amp;gt;[http://stackoverflow.com/questions/2198529/what-are-the-advantages-and-disadvantages-of-go-programming-language stackoverflow]&amp;lt;/ref&amp;gt;&lt;br /&gt;
*Go's not very usable on Windows yet.&lt;br /&gt;
*The packages distributed with Go are pretty useful, but there are still some libraries you'll miss. Most notably a UI toolkit.&lt;br /&gt;
*There is no support for generics in Go, although there are many discussions around it.&lt;br /&gt;
*Confusing Semantics Of Exported Identifiers&amp;lt;ref name = &amp;quot;Limitations2&amp;quot;&amp;gt;&lt;br /&gt;
[https://functionwhatwhat.com/go’s-type-system-is-an-embarrassment functionwhatwhat ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=87459</id>
		<title>CSC/ECE 517 Fall 2014/ch1a 10 hu</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=87459"/>
		<updated>2014-09-20T01:11:26Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Go''', also commonly referred to as '''golang''', is a compiled, concurrent, garbage-collected, statically typed language developed at [http://en.wikipedia.org/wiki/Google Google]. It was developed by [http://en.wikipedia.org/wiki/Robert_Griesemer Robert Griesemer], [http://en.wikipedia.org/wiki/Rob_Pike Rob Pike] and [http://en.wikipedia.org/wiki/Ken_Thompson Ken Thompson] in 2007. It was announced in November 2009 and is currently being used in many production systems at Google. It is an open source project. The syntax is loosely derived from that of [http://en.wikipedia.org/wiki/C_(programming_language) C programming language], adding [http://en.wikipedia.org/wiki/Garbage_collection_(computer_science) Garbage collection], type safety, some dynamic-typing capabilities. Additional built-in types such as variable-length arrays and key-value maps, and a large standard library are also supported. Different operating systems like Linux, Microsoft Windows, Mac OS X are suported by gc compiler of Go.&lt;br /&gt;
&lt;br /&gt;
=Background=&lt;br /&gt;
&lt;br /&gt;
Go programming started of as a research project by Robert Griesemer, Rob Pike and Ken Thompson. They felt that there was no new system focused programming language that has come up in the last decade till 2008, while there were other developments like increase in the size of libraries, dominance of networking , client server focus, multi-core CPUs.&amp;lt;ref name = &amp;quot;Background 1&amp;quot;&amp;gt;[https://www.youtube.com/watch?v=rKnDgT73v8s Go Language Introduction speech]&amp;lt;/ref&amp;gt; So they wanted to come up with a new systems focused programming language that would address the above issues.&amp;lt;ref name=&amp;quot;BG2&amp;quot;&amp;gt;[http://techcrunch.com/2009/11/10/google-go-language TechCrunch]&amp;lt;/ref&amp;gt; They started sketching the goals for a new language on the white board on September 21, 2007. Within a few days the goals had settled into a plan to do something and a fair idea of what it would be. Design continued part-time in parallel with unrelated work.&lt;br /&gt;
By January 2008, Ken had started work on a compiler with which to explore ideas; it generated C code as its output. By mid-year the language had become a full-time project and had settled enough to attempt a production compiler. In May 2008, [http://research.google.com/pubs/author37504.html Ian Taylor] independently started on a [http://en.wikipedia.org/wiki/GNU_Compiler_Collection GCC] front end for Go using the draft specification.  [http://russ.cox.usesthis.com/ Russ Cox] joined in late 2008 and helped move the language and libraries from prototype to reality.&lt;br /&gt;
Go became a public [http://en.wikipedia.org/wiki/Open_source open source project] on November 10, 2009. Many people from the community have contributed ideas, discussions, and code.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Compilers and Runtime support=&lt;br /&gt;
&lt;br /&gt;
There are two Go compiler implementations, [https://golang.org/cmd/gc Gc] (the 6g program and friends) and [http://blog.golang.org/gccgo-in-gcc-471 gccgo ]. Gc uses a different calling convention and linker. It can therefore only be linked with C programs using the same convention. Gccgo is a GCC front-end that can be linked with GCC-compiled C or C++ programs.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cgo program provides the mechanism for a “foreign function interface” to allow safe calling of C libraries from Go code. [http://en.wikipedia.org/wiki/SWIG SWIG] extends this capability to C++ libraries. &lt;br /&gt;
&lt;br /&gt;
Again due to bootstrapping issues, the run-time code is mostly in C (with a tiny bit of assembler) although Go is capable of implementing most of it now. Gccgo's run-time support uses glibc. Gc uses a custom library to keep the footprint under control; it is compiled with a version of the [http://plan9.bell-labs.com/sys/doc/compiler.html Plan 9 C compiler] that supports resizable stacks for goroutines. The gccgo compiler implements these on Linux only, using a technique called segmented stacks, supported by recent modifications to the gold linker.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find all resources needed to compile and run Go Language here http://go-lang.cat-v.org/&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
 &lt;br /&gt;
Programming today involves too much bookkeeping, repetition, and clerical work. As Dick Gabriel says, “Old programs read like quiet conversations between a well-spoken research worker and a well-studied mechanical colleague, not as a debate with a compiler. Who'd have guessed sophistication bought such noise?” The sophistication is worthwhile—no one wants to go back to the old languages—but can it be more quietly achieved?&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Go attempts to reduce the amount of typing in both senses of the word. Throughout its design, &lt;br /&gt;
*They have tried to reduce clutter and complexity. &lt;br /&gt;
*There are no forward declarations and no header files. everything is declared exactly once. &lt;br /&gt;
*Initialization is expressive, automatic, and easy to use. &lt;br /&gt;
*Syntax is clean and light on keywords. Stuttering (foo.Foo* myFoo = new(foo.Foo)) is reduced by simple type derivation using the := declare-and-initialize construct. &lt;br /&gt;
*And perhaps most radically, there is no type hierarchy. They don't have to announce their relationships.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
These simplifications allow Go to be expressive yet comprehensible without sacrificing, well, sophistication.&lt;br /&gt;
Another important principle is to keep the concepts orthogonal. Methods can be implemented for any type; structures represent data while interfaces represent abstraction; and so on. Orthogonality makes it easier to understand what happens when things combine.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Language Design=&lt;br /&gt;
==Syntax==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 package main //line 1&lt;br /&gt;
&lt;br /&gt;
   import “fmt”  //line 2&lt;br /&gt;
&lt;br /&gt;
   func main() {  //line 3&lt;br /&gt;
&lt;br /&gt;
       fmt.Println(“Hello World”) //line 4&lt;br /&gt;
&lt;br /&gt;
   } //line 5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Line1 specifies package declaration. Package is used to organize and reuse code. Line 2 is used for including the package “fmt” which is used for formatting input and output. Line 3 to 5 defines the function main. main is the function which is called when a program is executed. Println function in fmt is used to display content to the console i.e in this example Hello World is displayed in the console on executing the program.&lt;br /&gt;
&lt;br /&gt;
==Code Conventions and Style==&lt;br /&gt;
&lt;br /&gt;
* Go fmt tool is used to automatically standardize indentation, spaces and surface-level code details. go vet and go link are perform checking automatically.&lt;br /&gt;
* Using tools and libraries provided in Go, there are standard approaches for API documentation(go doc), testing(go test), building(go build) and package management(go get).&lt;br /&gt;
* Syntax prevents any kind of cyclic dependencies.&lt;br /&gt;
* Unused variables and imports are not allowed.&lt;br /&gt;
* Elimination of functional programming constructs (such as map and try/finally in C++) ensure a concrete and explicit programming style.&lt;br /&gt;
&lt;br /&gt;
==Types==&lt;br /&gt;
&lt;br /&gt;
* Numbers are represented in Go as either Integers or Floating point numbers.&lt;br /&gt;
**Integers: Used to represent numbers without a decimal component. Different integers supported by Go are: uint8, uint16, uint32, uint64, int8, int16, int32, int64. Uint is used for unsigned integers and int for signed. 8,16, 32, 64 indicate the number of bits each type would use.&lt;br /&gt;
**Floating Point Integers: Used to support decimal components. Go supports float32 and float64 to represent floating point numbers and complex32 and complex64 to represent complex numbers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var x int32 =4&lt;br /&gt;
var y float32 = 4.5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* String: String litersals can be created using either double quotes(“Hello”) or back ticks(`Hello`). Strings have several operations associated them, for example one can find the length of the string or get a character at a specific index in a string.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
	fmt.Println(len(“Hello”)) // output: 5&lt;br /&gt;
	fmt.Println(“Hello”[1]) // output: 1&lt;br /&gt;
	fmt.Println(“Hello “+”Tom”) //output: Hello Tom&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Boolean: A 1 bit value is used to represent true or false.&lt;br /&gt;
&lt;br /&gt;
==Variables and Constants==&lt;br /&gt;
*Variabes in Go are indicated using the var keyword. Example: var x string=”hello” . They can also be shorthanded as x:=”hello” .&lt;br /&gt;
*The variable names should begin with a letter and can contain letters, digits or underscore character.&lt;br /&gt;
*The scope of the variable is the block in which it is defined and an attempt to access it outside the block would result in an error on running the program.&lt;br /&gt;
*Go provides support for constants (i.e. variables whose value can not be changed), using the const keyword. Example: const temp string = “Hello”&lt;br /&gt;
*In Go one can define multiple variables(or constants) using the following syntax:&lt;br /&gt;
    var(&lt;br /&gt;
         t1 =1&lt;br /&gt;
         t2=2&lt;br /&gt;
         t3=3&lt;br /&gt;
        t4=4&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Control Structures==&lt;br /&gt;
*For: It is used for repeating a list of statement(s) multiple times. The example below is used for calculating sum of numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    i := 1&lt;br /&gt;
    sum := 0&lt;br /&gt;
&lt;br /&gt;
    for i &amp;lt;= 10 {&lt;br /&gt;
        sum = sum + i&lt;br /&gt;
        i = i + 1&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    fmt.Println(“Sum:” + sum)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the example above i is a loop counter variable and is used to ensure that sum of numbers from 1 to 10 is computed. It indicates the number of times the statements inside the for loop is to be executed. The statement following the keyword for should evaluate to either true or false. If it is evaluated to true the body of for is executed, else we come out of the for loop.&lt;br /&gt;
&lt;br /&gt;
*If: Used to execute a block of statement(s) based on the evaluation of an expression to either true or false. It can also have an else associated with it.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    if i % 2 == 0 {&lt;br /&gt;
        fmt.Println(i + ” is divisble by 2”)&lt;br /&gt;
    } else {&lt;br /&gt;
        fmt.Println(i + “is not divisible by 2”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Switch: The value of the expression following switch is evaluated and is compared against the different cases. Based on the matching case, the block following that case is executed. Switch also has a default case in situations when none of the cases are matching.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    // if op ==1 then so a+b&lt;br /&gt;
    // if op == 2 then do a-b&lt;br /&gt;
    // if op == 3 then do a*b&lt;br /&gt;
    // if op ==4 then do a/b&lt;br /&gt;
    // default print, invalid operator&lt;br /&gt;
&lt;br /&gt;
    op:= 1&lt;br /&gt;
    a=6&lt;br /&gt;
    b=7&lt;br /&gt;
    switch(op) {&lt;br /&gt;
        case 1: fmt.Println(a+b)&lt;br /&gt;
        case 2: fmt.Println(a-b)&lt;br /&gt;
        case 3: fmt.Println(a*b)&lt;br /&gt;
        case 4: fmt.Println(a/b)&lt;br /&gt;
        default: fmt.Println(“Invalid Operator”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Arrays, Slices and Maps==&lt;br /&gt;
&lt;br /&gt;
*Arrays: Numbered sequence of elements starting with index zero and each of the elements having a fixed length. The example below illustrates various operations performed on arrays in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
    var x[10] int&lt;br /&gt;
    x[99]=100&lt;br /&gt;
    fmt.Println(x)  //[0 0 ….. 0 100]&lt;br /&gt;
    fmt.Println(len(x)) //100&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Slices: &lt;br /&gt;
** It is a segment of an array.&lt;br /&gt;
** They have a length and are indexable.&lt;br /&gt;
**In case of a slice the size does not have to specified in the square bracket.&lt;br /&gt;
**Slices support two in-build functions: copy and append.&lt;br /&gt;
**The program below illustrates the different ways to create slices and use of copy and append.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    arr := [10] int {1,2,3,4,5,6,7,8,9,10}&lt;br /&gt;
    x := make([]int,10) // creates a slice [1...10]&lt;br /&gt;
    y := make([]int,10,10) //creates a slice [1...10]&lt;br /&gt;
    z := arr[0:10] //creates a slice [1...10]&lt;br /&gt;
    s1 := []int{1,2,3,4,5}&lt;br /&gt;
    s2 := append(s1, 6, 7)&lt;br /&gt;
    fmt.Println(s1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(s2) // [1,2,3,4,5,6,7]&lt;br /&gt;
    p1 := [] int{1,2,3,4,5}&lt;br /&gt;
    p2 :=make([]int, 4)&lt;br /&gt;
    copy(p2,p1)&lt;br /&gt;
    fmt.Println(p1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(p2)// [1,2,3,4]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Maps:&lt;br /&gt;
**A map is an unordered collection of key value pairs.&lt;br /&gt;
**Syntax: var x map[int] string , where int is the type of the key and string is the type of the value.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
    x := make(map[int]string)&lt;br /&gt;
    x[1] = one&lt;br /&gt;
    x[2] = two&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
&lt;br /&gt;
*In Go functions can take multiple inputs and return multiple outputs.&lt;br /&gt;
*Go supports a special kind of function called variadic function.&lt;br /&gt;
*Closure is the means by which functions can be created inside other function in Go.&lt;br /&gt;
*Go supports recursive functions.&lt;br /&gt;
*The example below the different types of function in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    display(“Hello World”)&lt;br /&gt;
    sum :=calculateSum(10,20)&lt;br /&gt;
    v1,v2=multipleValues()&lt;br /&gt;
    p=product(5,10,20)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function without return type&lt;br /&gt;
func display( s string) {&lt;br /&gt;
    fmt.Println(s)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns a single value&lt;br /&gt;
func calculateSum(a int, b int) int {&lt;br /&gt;
    c: = a + b&lt;br /&gt;
    return c&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns multiple values&lt;br /&gt;
func multipleValues(int, int) {&lt;br /&gt;
    return 1, 2&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Variadic function&lt;br /&gt;
func product(args ...int) int {&lt;br /&gt;
    p := 1&lt;br /&gt;
   for _, i := range args {&lt;br /&gt;
        p *= i&lt;br /&gt;
   }&lt;br /&gt;
   return p&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pointers==&lt;br /&gt;
It is used to reference a location in the memory where the value is stored rather than containing the value itself. Basic pointer operations in Go are illustrated in the example below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
//Different syntax for pointers&lt;br /&gt;
    &lt;br /&gt;
     ptr1 *int&lt;br /&gt;
     num :=10&lt;br /&gt;
     ptr1 = &amp;amp;num&lt;br /&gt;
     ptr2 := new(int)&lt;br /&gt;
     ptr2=&amp;amp;num&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Concurrency==&lt;br /&gt;
* Go ensures concurrency which allows sharing of state using communication mechanisms.&lt;br /&gt;
* Go provides support for multithreading and CPU parallelization.&lt;br /&gt;
* Go supports asynchrony i.e. allows operations like database and network I/O which are slow operations to occur in parallel along with other operations.&lt;br /&gt;
* A new lightweight process is created using&lt;br /&gt;
&lt;br /&gt;
=Users of Go=&lt;br /&gt;
Apart from Google, which uses Go programming for some of its development, companies like [http://en.wikipedia.org/wiki/Dropbox_(service) Dropbox], [http://en.wikipedia.org/wiki/CloudFlare CloudFlare], [http://en.wikipedia.org/wiki/SoundCloud SoundCloud], The BBC, Novartis, Cloud Foundry also use Go programming.  &lt;br /&gt;
Dropbox server (running in the cloud) and desktop client software were primarily written in [http://en.wikipedia.org/wiki/Python_(programming_language) Python]. From mid-2013 Dropbox began migrating its backend infrastructure to Go.&lt;br /&gt;
Some of the open-source applications that are using Go programming are Docker, Flynn, PaaS, Juju, nsq, Doozer e.t.c&lt;br /&gt;
&lt;br /&gt;
=Advantages=&lt;br /&gt;
 &lt;br /&gt;
*'''C Level Performance'''. golang is within a close margin of the performance level of C code (which is itself an extremely high performance language). It is certainly closer to the performance of native languages than other enterprise level languages such as Java, Scala, Erlang etc.&lt;br /&gt;
 &lt;br /&gt;
*'''Fast Compilation''' is one of the key advantages of Go language. The Golang compiler was designed to compile programs very quickly. Extremely large programs with massively high LOC counts compile seemingly instantly - after all, Golang was designed by Google to solve Google problems, and Google has big problems! At Google, code and CPU cores are both measured in the millions. Go provides a model for software construction that makes dependency analysis easy and avoids much of the overhead of C-style include files and libraries.&lt;br /&gt;
&lt;br /&gt;
Reduced compile time is a key improvement in the Go language&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      If A.go depends on B.go depends on C.go :&lt;br /&gt;
         Compile C.go, B.go then A.go normally (other languages)&lt;br /&gt;
         To compile A.go, compiler reads B.o not C.o (go)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At a large scale this should help in hugely speeding up&lt;br /&gt;
&lt;br /&gt;
Other advantages are      &lt;br /&gt;
* '''Concurrency Supported At Language Level'''. Concurrency is the ability to execute multiple computations simultaneously. In today's modern multicore and high-load computing environment, concurrency is a critical language feature, and one in which languages such as Java struggle immensely.&lt;br /&gt;
* By its design, Go proposes an approach for the construction of system software on '''multicore machines'''.&lt;br /&gt;
* Google have summed things up nicely with their motto: '''Don't communicate by sharing memory, share memory by communicating'''.Channels allow you to pass references to data structures between goroutines. If you consider this as passing around ownership of the data (the ability to read and write it), they become a powerful and expressive synchronization mechanism.  &lt;br /&gt;
* '''Go's type system has no hierarchy''', so no time is spent defining the relationships between types. Also, although Go has static types, the language attempts to make types feel lighter weight than in typical Object Oriented languages.&lt;br /&gt;
* '''Garbage Collection is much better'''. In C and C++, programmers spend a lot of time and energy on allocating and freeing memory. The designers of Go wanted to remove that complication, and ensure Go programmers could concentrate on more productive tasks. As such, they implemented garbage collection. As a developer, this is a very good thing. Sure, garbage collection comes with its own set of issues, but those are dealt with by the language implementer while the programmer is free to reap the other many benefits of Go.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
*Go is still an experimental language subject to change.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;&amp;gt;[http://stackoverflow.com/questions/2198529/what-are-the-advantages-and-disadvantages-of-go-programming-language stackoverflow]&amp;lt;/ref&amp;gt;&lt;br /&gt;
*Go's not very usable on Windows yet.&lt;br /&gt;
*The packages distributed with Go are pretty useful, but there are still some libraries you'll miss. Most notably a UI toolkit.&lt;br /&gt;
*There is no support for generics in Go, although there are many discussions around it.&lt;br /&gt;
*Confusing Semantics Of Exported Identifiers&amp;lt;ref name = &amp;quot;Limitations2&amp;quot;&amp;gt;&lt;br /&gt;
[https://functionwhatwhat.com/go’s-type-system-is-an-embarrassment functionwhatwhat ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=87437</id>
		<title>CSC/ECE 517 Fall 2014/ch1a 10 hu</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=87437"/>
		<updated>2014-09-20T01:03:17Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Concurrency */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Go''', also commonly referred to as '''golang''', is a compiled, concurrent, garbage-collected, statically typed language developed at [http://en.wikipedia.org/wiki/Google Google]. It was developed by [http://en.wikipedia.org/wiki/Robert_Griesemer Robert Griesemer], [http://en.wikipedia.org/wiki/Rob_Pike Rob Pike] and [http://en.wikipedia.org/wiki/Ken_Thompson Ken Thompson] in 2007. It was announced in November 2009 and is currently being used in many production systems at Google. It is an open source project. The syntax is loosely derived from that of [http://en.wikipedia.org/wiki/C_(programming_language) C programming language], adding [http://en.wikipedia.org/wiki/Garbage_collection_(computer_science) Garbage collection], type safety, some dynamic-typing capabilities. Additional built-in types such as variable-length arrays and key-value maps, and a large standard library are also supported. Go's &amp;quot;gc&amp;quot; compiler targets the [http://en.wikipedia.org/wiki/Linux Linux], [http://en.wikipedia.org/wiki/OS_X OS X], [http://en.wikipedia.org/wiki/FreeBSD FreeBSD], [http://en.wikipedia.org/wiki/NetBSD NetBSD], [http://en.wikipedia.org/wiki/OpenBSD OpenBSD], and [http://en.wikipedia.org/wiki/Microsoft_Windows Microsoft Windows] operating systems and the i386, amd64, and ARM processor architectures. &lt;br /&gt;
 &lt;br /&gt;
=Background=&lt;br /&gt;
&lt;br /&gt;
Go programming started of as a research project by Robert Griesemer, Rob Pike and Ken Thompson. They felt that there was no new system focused programming language that has come up in the last decade till 2008, while there were other developments like increase in the size of libraries, dominance of networking , client server focus, multi-core CPUs.&amp;lt;ref name = &amp;quot;Background 1&amp;quot;&amp;gt;[https://www.youtube.com/watch?v=rKnDgT73v8s Go Language release]&amp;lt;/ref&amp;gt; So they wanted to come up with a new systems focused programming language that would address the above issues.&amp;lt;ref name=&amp;quot;BG2&amp;quot;&amp;gt;[http://techcrunch.com/2009/11/10/google-go-language TechCrunch]&amp;lt;/ref&amp;gt; They started sketching the goals for a new language on the white board on September 21, 2007. Within a few days the goals had settled into a plan to do something and a fair idea of what it would be. Design continued part-time in parallel with unrelated work.&lt;br /&gt;
By January 2008, Ken had started work on a compiler with which to explore ideas; it generated C code as its output. By mid-year the language had become a full-time project and had settled enough to attempt a production compiler. In May 2008, [http://research.google.com/pubs/author37504.html Ian Taylor] independently started on a [http://en.wikipedia.org/wiki/GNU_Compiler_Collection GCC] front end for Go using the draft specification.  [http://russ.cox.usesthis.com/ Russ Cox] joined in late 2008 and helped move the language and libraries from prototype to reality.&lt;br /&gt;
Go became a public [http://en.wikipedia.org/wiki/Open_source open source project] on November 10, 2009. Many people from the community have contributed ideas, discussions, and code.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Compilers and Runtime support=&lt;br /&gt;
&lt;br /&gt;
There are two Go compiler implementations, [https://golang.org/cmd/gc Gc] (the 6g program and friends) and [http://blog.golang.org/gccgo-in-gcc-471 gccgo ]. Gc uses a different calling convention and linker. It can therefore only be linked with C programs using the same convention. Gccgo is a GCC front-end that can be linked with GCC-compiled C or C++ programs.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cgo program provides the mechanism for a “foreign function interface” to allow safe calling of C libraries from Go code. [http://en.wikipedia.org/wiki/SWIG SWIG] extends this capability to C++ libraries. &lt;br /&gt;
&lt;br /&gt;
Again due to bootstrapping issues, the run-time code is mostly in C (with a tiny bit of assembler) although Go is capable of implementing most of it now. Gccgo's run-time support uses glibc. Gc uses a custom library to keep the footprint under control; it is compiled with a version of the [http://plan9.bell-labs.com/sys/doc/compiler.html Plan 9 C compiler] that supports resizable stacks for goroutines. The gccgo compiler implements these on Linux only, using a technique called segmented stacks, supported by recent modifications to the gold linker.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find all resources needed to compile and run Go Language here http://go-lang.cat-v.org/&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
 &lt;br /&gt;
Programming today involves too much bookkeeping, repetition, and clerical work. As Dick Gabriel says, “Old programs read like quiet conversations between a well-spoken research worker and a well-studied mechanical colleague, not as a debate with a compiler. Who'd have guessed sophistication bought such noise?” The sophistication is worthwhile—no one wants to go back to the old languages—but can it be more quietly achieved?&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Go attempts to reduce the amount of typing in both senses of the word. Throughout its design, &lt;br /&gt;
*They have tried to reduce clutter and complexity. &lt;br /&gt;
*There are no forward declarations and no header files. everything is declared exactly once. &lt;br /&gt;
*Initialization is expressive, automatic, and easy to use. &lt;br /&gt;
*Syntax is clean and light on keywords. Stuttering (foo.Foo* myFoo = new(foo.Foo)) is reduced by simple type derivation using the := declare-and-initialize construct. &lt;br /&gt;
*And perhaps most radically, there is no type hierarchy. They don't have to announce their relationships.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
These simplifications allow Go to be expressive yet comprehensible without sacrificing, well, sophistication.&lt;br /&gt;
Another important principle is to keep the concepts orthogonal. Methods can be implemented for any type; structures represent data while interfaces represent abstraction; and so on. Orthogonality makes it easier to understand what happens when things combine.&amp;lt;ref name = &amp;quot;Google_FAQ&amp;quot;&amp;gt;[https://golang.org/doc/faq golang FAQs]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Language Design=&lt;br /&gt;
==Syntax==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 package main //line 1&lt;br /&gt;
&lt;br /&gt;
   import “fmt”  //line 2&lt;br /&gt;
&lt;br /&gt;
   func main() {  //line 3&lt;br /&gt;
&lt;br /&gt;
       fmt.Println(“Hello World”) //line 4&lt;br /&gt;
&lt;br /&gt;
   } //line 5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Line1 specifies package declaration. Package is used to organize and reuse code. Line 2 is used for including the package “fmt” which is used for formatting input and output. Line 3 to 5 defines the function main. main is the function which is called when a program is executed. Println function in fmt is used to display content to the console i.e in this example Hello World is displayed in the console on executing the program.&lt;br /&gt;
&lt;br /&gt;
==Code Conventions and Style==&lt;br /&gt;
&lt;br /&gt;
* Go fmt tool is used to automatically standardize indentation, spaces and surface-level code details. go vet and go link are perform checking automatically.&lt;br /&gt;
* Using tools and libraries provided in Go, there are standard approaches for API documentation(go doc), testing(go test), building(go build) and package management(go get).&lt;br /&gt;
* Syntax prevents any kind of cyclic dependencies.&lt;br /&gt;
* Unused variables and imports are not allowed.&lt;br /&gt;
* Elimination of functional programming constructs (such as map and try/finally in C++) ensure a concrete and explicit programming style.&lt;br /&gt;
&lt;br /&gt;
==Types==&lt;br /&gt;
&lt;br /&gt;
* Numbers are represented in Go as either Integers or Floating point numbers.&lt;br /&gt;
**Integers: Used to represent numbers without a decimal component. Different integers supported by Go are: uint8, uint16, uint32, uint64, int8, int16, int32, int64. Uint is used for unsigned integers and int for signed. 8,16, 32, 64 indicate the number of bits each type would use.&lt;br /&gt;
**Floating Point Integers: Used to support decimal components. Go supports float32 and float64 to represent floating point numbers and complex32 and complex64 to represent complex numbers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var x int32 =4&lt;br /&gt;
var y float32 = 4.5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* String: String litersals can be created using either double quotes(“Hello”) or back ticks(`Hello`). Strings have several operations associated them, for example one can find the length of the string or get a character at a specific index in a string.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
	fmt.Println(len(“Hello”)) // output: 5&lt;br /&gt;
	fmt.Println(“Hello”[1]) // output: 1&lt;br /&gt;
	fmt.Println(“Hello “+”Tom”) //output: Hello Tom&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Boolean: A 1 bit value is used to represent true or false.&lt;br /&gt;
&lt;br /&gt;
==Variables and Constants==&lt;br /&gt;
*Variabes in Go are indicated using the var keyword. Example: var x string=”hello” . They can also be shorthanded as x:=”hello” .&lt;br /&gt;
*The variable names should begin with a letter and can contain letters, digits or underscore character.&lt;br /&gt;
*The scope of the variable is the block in which it is defined and an attempt to access it outside the block would result in an error on running the program.&lt;br /&gt;
*Go provides support for constants (i.e. variables whose value can not be changed), using the const keyword. Example: const temp string = “Hello”&lt;br /&gt;
*In Go one can define multiple variables(or constants) using the following syntax:&lt;br /&gt;
    var(&lt;br /&gt;
         t1 =1&lt;br /&gt;
         t2=2&lt;br /&gt;
         t3=3&lt;br /&gt;
        t4=4&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Control Structures==&lt;br /&gt;
*For: It is used for repeating a list of statement(s) multiple times. The example below is used for calculating sum of numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    i := 1&lt;br /&gt;
    sum := 0&lt;br /&gt;
&lt;br /&gt;
    for i &amp;lt;= 10 {&lt;br /&gt;
        sum = sum + i&lt;br /&gt;
        i = i + 1&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    fmt.Println(“Sum:” + sum)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the example above i is a loop counter variable and is used to ensure that sum of numbers from 1 to 10 is computed. It indicates the number of times the statements inside the for loop is to be executed. The statement following the keyword for should evaluate to either true or false. If it is evaluated to true the body of for is executed, else we come out of the for loop.&lt;br /&gt;
&lt;br /&gt;
*If: Used to execute a block of statement(s) based on the evaluation of an expression to either true or false. It can also have an else associated with it.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    if i % 2 == 0 {&lt;br /&gt;
        fmt.Println(i + ” is divisble by 2”)&lt;br /&gt;
    } else {&lt;br /&gt;
        fmt.Println(i + “is not divisible by 2”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Switch: The value of the expression following switch is evaluated and is compared against the different cases. Based on the matching case, the block following that case is executed. Switch also has a default case in situations when none of the cases are matching.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    // if op ==1 then so a+b&lt;br /&gt;
    // if op == 2 then do a-b&lt;br /&gt;
    // if op == 3 then do a*b&lt;br /&gt;
    // if op ==4 then do a/b&lt;br /&gt;
    // default print, invalid operator&lt;br /&gt;
&lt;br /&gt;
    op:= 1&lt;br /&gt;
    a=6&lt;br /&gt;
    b=7&lt;br /&gt;
    switch(op) {&lt;br /&gt;
        case 1: fmt.Println(a+b)&lt;br /&gt;
        case 2: fmt.Println(a-b)&lt;br /&gt;
        case 3: fmt.Println(a*b)&lt;br /&gt;
        case 4: fmt.Println(a/b)&lt;br /&gt;
        default: fmt.Println(“Invalid Operator”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Arrays, Slices and Maps==&lt;br /&gt;
&lt;br /&gt;
*Arrays: Numbered sequence of elements starting with index zero and each of the elements having a fixed length. The example below illustrates various operations performed on arrays in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
    var x[10] int&lt;br /&gt;
    x[99]=100&lt;br /&gt;
    fmt.Println(x)  //[0 0 ….. 0 100]&lt;br /&gt;
    fmt.Println(len(x)) //100&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Slices: &lt;br /&gt;
** It is a segment of an array.&lt;br /&gt;
** They have a length and are indexable.&lt;br /&gt;
**In case of a slice the size does not have to specified in the square bracket.&lt;br /&gt;
**Slices support two in-build functions: copy and append.&lt;br /&gt;
**The program below illustrates the different ways to create slices and use of copy and append.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    arr := [10] int {1,2,3,4,5,6,7,8,9,10}&lt;br /&gt;
    x := make([]int,10) // creates a slice [1...10]&lt;br /&gt;
    y := make([]int,10,10) //creates a slice [1...10]&lt;br /&gt;
    z := arr[0:10] //creates a slice [1...10]&lt;br /&gt;
    s1 := []int{1,2,3,4,5}&lt;br /&gt;
    s2 := append(s1, 6, 7)&lt;br /&gt;
    fmt.Println(s1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(s2) // [1,2,3,4,5,6,7]&lt;br /&gt;
    p1 := [] int{1,2,3,4,5}&lt;br /&gt;
    p2 :=make([]int, 4)&lt;br /&gt;
    copy(p2,p1)&lt;br /&gt;
    fmt.Println(p1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(p2)// [1,2,3,4]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Maps:&lt;br /&gt;
**A map is an unordered collection of key value pairs.&lt;br /&gt;
**Syntax: var x map[int] string , where int is the type of the key and string is the type of the value.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
    x := make(map[int]string)&lt;br /&gt;
    x[1] = one&lt;br /&gt;
    x[2] = two&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
&lt;br /&gt;
*In Go functions can take multiple inputs and return multiple outputs.&lt;br /&gt;
*Go supports a special kind of function called variadic function.&lt;br /&gt;
*Closure is the means by which functions can be created inside other function in Go.&lt;br /&gt;
*Go supports recursive functions.&lt;br /&gt;
*The example below the different types of function in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    display(“Hello World”)&lt;br /&gt;
    sum :=calculateSum(10,20)&lt;br /&gt;
    v1,v2=multipleValues()&lt;br /&gt;
    p=product(5,10,20)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function without return type&lt;br /&gt;
func display( s string) {&lt;br /&gt;
    fmt.Println(s)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns a single value&lt;br /&gt;
func calculateSum(a int, b int) int {&lt;br /&gt;
    c: = a + b&lt;br /&gt;
    return c&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns multiple values&lt;br /&gt;
func multipleValues(int, int) {&lt;br /&gt;
    return 1, 2&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Variadic function&lt;br /&gt;
func product(args ...int) int {&lt;br /&gt;
    p := 1&lt;br /&gt;
   for _, i := range args {&lt;br /&gt;
        p *= i&lt;br /&gt;
   }&lt;br /&gt;
   return p&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pointers==&lt;br /&gt;
It is used to reference a location in the memory where the value is stored rather than containing the value itself. Basic pointer operations in Go are illustrated in the example below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
//Different syntax for pointers&lt;br /&gt;
    &lt;br /&gt;
     ptr1 *int&lt;br /&gt;
     num :=10&lt;br /&gt;
     ptr1 = &amp;amp;num&lt;br /&gt;
     ptr2 := new(int)&lt;br /&gt;
     ptr2=&amp;amp;num&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Concurrency==&lt;br /&gt;
* Go ensures concurrency which allows sharing of state using communication mechanisms.&lt;br /&gt;
* Go provides support for multithreading and CPU parallelization.&lt;br /&gt;
* Go supports asynchrony i.e. allows operations like database and network I/O which are slow operations to occur in parallel along with other operations.&lt;br /&gt;
* A new lightweight process is created using&lt;br /&gt;
&lt;br /&gt;
=Users of Go=&lt;br /&gt;
Apart from Google, which uses Go programming for some of its development, companies like [http://en.wikipedia.org/wiki/Dropbox_(service) Dropbox], [http://en.wikipedia.org/wiki/CloudFlare CloudFlare], [http://en.wikipedia.org/wiki/SoundCloud SoundCloud], The BBC, Novartis, Cloud Foundry also use Go programming.  &lt;br /&gt;
Dropbox server (running in the cloud) and desktop client software were primarily written in [http://en.wikipedia.org/wiki/Python_(programming_language) Python]. From mid-2013 Dropbox began migrating its backend infrastructure to Go.&lt;br /&gt;
Some of the open-source applications that are using Go programming are Docker, Flynn, PaaS, Juju, nsq, Doozer e.t.c&lt;br /&gt;
&lt;br /&gt;
=Advantages=&lt;br /&gt;
 &lt;br /&gt;
C Level Performance -- golang is within a close margin of the performance level of C code (which is itself an extremely high performance language). It is certainly closer to the performance of native languages than other enterprise level languages such as Java, Scala, Erlang etc.&lt;br /&gt;
 &lt;br /&gt;
*'''Fast Compilation''' is one of the key advantages of Go language. The Golang compiler was designed to compile programs very quickly. Extremely large programs with massively high LOC counts compile seemingly instantly - after all, Golang was designed by Google to solve Google problems, and Google has big problems! At Google, code and CPU cores are both measured in the millions. Go provides a model for software construction that makes dependency analysis easy and avoids much of the overhead of C-style include files and libraries.&lt;br /&gt;
&lt;br /&gt;
Reduced compile time is a key improvement in the Go language&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      If A.go depends on B.go depends on C.go :&lt;br /&gt;
         Compile C.go, B.go then A.go normally (other languages)&lt;br /&gt;
         To compile A.go, compiler reads B.o not C.o (go)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At a large scale this should help in hugely speeding up&lt;br /&gt;
&lt;br /&gt;
Other advantages are      &lt;br /&gt;
* '''Concurrency Supported At Language Level'''. Concurrency is the ability to execute multiple computations simultaneously. In today's modern multicore and high-load computing environment, concurrency is a critical language feature, and one in which languages such as Java struggle immensely.&lt;br /&gt;
* By its design, Go proposes an approach for the construction of system software on '''multicore machines'''.&lt;br /&gt;
* Google have summed things up nicely with their motto: '''Don't communicate by sharing memory, share memory by communicating'''.Channels allow you to pass references to data structures between goroutines. If you consider this as passing around ownership of the data (the ability to read and write it), they become a powerful and expressive synchronization mechanism.  &lt;br /&gt;
* '''Go's type system has no hierarchy''', so no time is spent defining the relationships between types. Also, although Go has static types, the language attempts to make types feel lighter weight than in typical Object Oriented languages.&lt;br /&gt;
* '''Garbage Collection is much better'''. In C and C++, programmers spend a lot of time and energy on allocating and freeing memory. The designers of Go wanted to remove that complication, and ensure Go programmers could concentrate on more productive tasks. As such, they implemented garbage collection. As a developer, this is a very good thing. Sure, garbage collection comes with its own set of issues, but those are dealt with by the language implementer while the programmer is free to reap the other many benefits of Go.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
*Go is still an experimental language subject to change.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;&amp;gt;[http://stackoverflow.com/questions/2198529/what-are-the-advantages-and-disadvantages-of-go-programming-language stackoverflow]&amp;lt;/ref&amp;gt;&lt;br /&gt;
*Go's not very usable on Windows yet.&lt;br /&gt;
*The packages distributed with Go are pretty useful, but there are still some libraries you'll miss. Most notably a UI toolkit.&lt;br /&gt;
*There is no support for generics in Go, although there are many discussions around it.&lt;br /&gt;
*Confusing Semantics Of Exported Identifiers&amp;lt;ref name = &amp;quot;Limitations2&amp;quot;&amp;gt;&lt;br /&gt;
[https://functionwhatwhat.com/go’s-type-system-is-an-embarrassment functionwhatwhat ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=87384</id>
		<title>CSC/ECE 517 Fall 2014/ch1a 10 hu</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1a_10_hu&amp;diff=87384"/>
		<updated>2014-09-20T00:45:20Z</updated>

		<summary type="html">&lt;p&gt;Hmarfat: /* Concurrency */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Go''', also commonly referred to as '''golang''', is a compiled, concurrent, garbage-collected, statically typed language developed at [http://en.wikipedia.org/wiki/Google Google]. It was developed by [http://en.wikipedia.org/wiki/Robert_Griesemer Robert Griesemer], [http://en.wikipedia.org/wiki/Rob_Pike Rob Pike] and [http://en.wikipedia.org/wiki/Ken_Thompson Ken Thompson] in 2007. It was announced in November 2009 and is currently being used in many production systems at Google. It is an open source project. The syntax is loosely derived from that of [http://en.wikipedia.org/wiki/C_(programming_language) C programming language], adding [http://en.wikipedia.org/wiki/Garbage_collection_(computer_science) Garbage collection], type safety, some dynamic-typing capabilities. Additional built-in types such as variable-length arrays and key-value maps, and a large standard library are also supported. Go's &amp;quot;gc&amp;quot; compiler targets the [http://en.wikipedia.org/wiki/Linux Linux], [http://en.wikipedia.org/wiki/OS_X OS X], [http://en.wikipedia.org/wiki/FreeBSD FreeBSD], [http://en.wikipedia.org/wiki/NetBSD NetBSD], [http://en.wikipedia.org/wiki/OpenBSD OpenBSD], and [http://en.wikipedia.org/wiki/Microsoft_Windows Microsoft Windows] operating systems and the i386, amd64, and ARM processor architectures. &lt;br /&gt;
 &lt;br /&gt;
=Background=&lt;br /&gt;
&lt;br /&gt;
Go programming started of as a research project by Robert Griesemer, Rob Pike and Ken Thompson. They felt that there was no new system focused programming language that has come up in the last decade till 2008, while there were other developments like increase in the size of libraries, dominance of networking , client server focus, multi-core CPUs. So they wanted to come up with a new systems focused programming language that would address the above issues. They started sketching the goals for a new language on the white board on September 21, 2007. Within a few days the goals had settled into a plan to do something and a fair idea of what it would be. Design continued part-time in parallel with unrelated work.&lt;br /&gt;
By January 2008, Ken had started work on a compiler with which to explore ideas; it generated C code as its output. By mid-year the language had become a full-time project and had settled enough to attempt a production compiler. In May 2008, Ian Taylor independently started on a [http://en.wikipedia.org/wiki/GNU_Compiler_Collection GCC] front end for Go using the draft specification. Russ Cox joined in late 2008 and helped move the language and libraries from prototype to reality.&lt;br /&gt;
Go became a public open source project on November 10, 2009. Many people from the community have contributed ideas, discussions, and code.&lt;br /&gt;
&lt;br /&gt;
=Compilers and Runtime support=&lt;br /&gt;
&lt;br /&gt;
There are two Go compiler implementations, [https://golang.org/cmd/gc Gc] (the 6g program and friends) and [http://blog.golang.org/gccgo-in-gcc-471 gccgo ]. Gc uses a different calling convention and linker. It can therefore only be linked with C programs using the same convention. Gccgo is a GCC front-end that can be linked with GCC-compiled C or C++ programs.&lt;br /&gt;
&lt;br /&gt;
The cgo program provides the mechanism for a “foreign function interface” to allow safe calling of C libraries from Go code. [http://en.wikipedia.org/wiki/SWIG SWIG] extends this capability to C++ libraries. &lt;br /&gt;
&lt;br /&gt;
Again due to bootstrapping issues, the run-time code is mostly in C (with a tiny bit of assembler) although Go is capable of implementing most of it now. Gccgo's run-time support uses glibc. Gc uses a custom library to keep the footprint under control; it is compiled with a version of the [http://plan9.bell-labs.com/sys/doc/compiler.html Plan 9 C compiler] that supports resizable stacks for goroutines. The gccgo compiler implements these on Linux only, using a technique called segmented stacks, supported by recent modifications to the gold linker.&lt;br /&gt;
&lt;br /&gt;
You can find all resources needed to compile and run Go Language here http://go-lang.cat-v.org/&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
 &lt;br /&gt;
Programming today involves too much bookkeeping, repetition, and clerical work. As Dick Gabriel says, “Old programs read like quiet conversations between a well-spoken research worker and a well-studied mechanical colleague, not as a debate with a compiler. Who'd have guessed sophistication bought such noise?” The sophistication is worthwhile—no one wants to go back to the old languages—but can it be more quietly achieved?&lt;br /&gt;
 &lt;br /&gt;
Go attempts to reduce the amount of typing in both senses of the word. Throughout its design, &lt;br /&gt;
*They have tried to reduce clutter and complexity. &lt;br /&gt;
*There are no forward declarations and no header files. everything is declared exactly once. &lt;br /&gt;
*Initialization is expressive, automatic, and easy to use. &lt;br /&gt;
*Syntax is clean and light on keywords. Stuttering (foo.Foo* myFoo = new(foo.Foo)) is reduced by simple type derivation using the := declare-and-initialize construct. &lt;br /&gt;
*And perhaps most radically, there is no type hierarchy. They don't have to announce their relationships. &lt;br /&gt;
&lt;br /&gt;
These simplifications allow Go to be expressive yet comprehensible without sacrificing, well, sophistication.&lt;br /&gt;
Another important principle is to keep the concepts orthogonal. Methods can be implemented for any type; structures represent data while interfaces represent abstraction; and so on. Orthogonality makes it easier to understand what happens when things combine.&lt;br /&gt;
&lt;br /&gt;
=Language Design=&lt;br /&gt;
==Syntax==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 package main //line 1&lt;br /&gt;
&lt;br /&gt;
   import “fmt”  //line 2&lt;br /&gt;
&lt;br /&gt;
   func main() {  //line 3&lt;br /&gt;
&lt;br /&gt;
       fmt.Println(“Hello World”) //line 4&lt;br /&gt;
&lt;br /&gt;
   } //line 5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Line1 specifies package declaration. Package is used to organize and reuse code. Line 2 is used for including the package “fmt” which is used for formatting input and output. Line 3 to 5 defines the function main. main is the function which is called when a program is executed. Println function in fmt is used to display content to the console i.e in this example Hello World is displayed in the console on executing the program.&lt;br /&gt;
&lt;br /&gt;
==Code Conventions and Style==&lt;br /&gt;
&lt;br /&gt;
* Go fmt tool is used to automatically standardize indentation, spaces and surface-level code details. go vet and go link are perform checking automatically.&lt;br /&gt;
* Using tools and libraries provided in Go, there are standard approaches for API documentation(go doc), testing(go test), building(go build) and package management(go get).&lt;br /&gt;
* Syntax prevents any kind of cyclic dependencies.&lt;br /&gt;
* Unused variables and imports are not allowed.&lt;br /&gt;
* Elimination of functional programming constructs (such as map and try/finally in C++) ensure a concrete and explicit programming style.&lt;br /&gt;
&lt;br /&gt;
==Types==&lt;br /&gt;
&lt;br /&gt;
* Numbers are represented in Go as either Integers or Floating point numbers.&lt;br /&gt;
**Integers: Used to represent numbers without a decimal component. Different integers supported by Go are: uint8, uint16, uint32, uint64, int8, int16, int32, int64. Uint is used for unsigned integers and int for signed. 8,16, 32, 64 indicate the number of bits each type would use.&lt;br /&gt;
**Floating Point Integers: Used to support decimal components. Go supports float32 and float64 to represent floating point numbers and complex32 and complex64 to represent complex numbers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var x int32 =4&lt;br /&gt;
var y float32 = 4.5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* String: String litersals can be created using either double quotes(“Hello”) or back ticks(`Hello`). Strings have several operations associated them, for example one can find the length of the string or get a character at a specific index in a string.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
	fmt.Println(len(“Hello”)) // output: 5&lt;br /&gt;
	fmt.Println(“Hello”[1]) // output: 1&lt;br /&gt;
	fmt.Println(“Hello “+”Tom”) //output: Hello Tom&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Boolean: A 1 bit value is used to represent true or false.&lt;br /&gt;
&lt;br /&gt;
==Variables and Constants==&lt;br /&gt;
*Variabes in Go are indicated using the var keyword. Example: var x string=”hello” . They can also be shorthanded as x:=”hello” .&lt;br /&gt;
*The variable names should begin with a letter and can contain letters, digits or underscore character.&lt;br /&gt;
*The scope of the variable is the block in which it is defined and an attempt to access it outside the block would result in an error on running the program.&lt;br /&gt;
*Go provides support for constants (i.e. variables whose value can not be changed), using the const keyword. Example: const temp string = “Hello”&lt;br /&gt;
*In Go one can define multiple variables(or constants) using the following syntax:&lt;br /&gt;
    var(&lt;br /&gt;
         t1 =1&lt;br /&gt;
         t2=2&lt;br /&gt;
         t3=3&lt;br /&gt;
        t4=4&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Control Structures==&lt;br /&gt;
*For: It is used for repeating a list of statement(s) multiple times. The example below is used for calculating sum of numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    i := 1&lt;br /&gt;
    sum := 0&lt;br /&gt;
&lt;br /&gt;
    for i &amp;lt;= 10 {&lt;br /&gt;
        sum = sum + i&lt;br /&gt;
        i = i + 1&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    fmt.Println(“Sum:” + sum)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the example above i is a loop counter variable and is used to ensure that sum of numbers from 1 to 10 is computed. It indicates the number of times the statements inside the for loop is to be executed. The statement following the keyword for should evaluate to either true or false. If it is evaluated to true the body of for is executed, else we come out of the for loop.&lt;br /&gt;
&lt;br /&gt;
*If: Used to execute a block of statement(s) based on the evaluation of an expression to either true or false. It can also have an else associated with it.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    if i % 2 == 0 {&lt;br /&gt;
        fmt.Println(i + ” is divisble by 2”)&lt;br /&gt;
    } else {&lt;br /&gt;
        fmt.Println(i + “is not divisible by 2”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Switch: The value of the expression following switch is evaluated and is compared against the different cases. Based on the matching case, the block following that case is executed. Switch also has a default case in situations when none of the cases are matching.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    // if op ==1 then so a+b&lt;br /&gt;
    // if op == 2 then do a-b&lt;br /&gt;
    // if op == 3 then do a*b&lt;br /&gt;
    // if op ==4 then do a/b&lt;br /&gt;
    // default print, invalid operator&lt;br /&gt;
&lt;br /&gt;
    op:= 1&lt;br /&gt;
    a=6&lt;br /&gt;
    b=7&lt;br /&gt;
    switch(op) {&lt;br /&gt;
        case 1: fmt.Println(a+b)&lt;br /&gt;
        case 2: fmt.Println(a-b)&lt;br /&gt;
        case 3: fmt.Println(a*b)&lt;br /&gt;
        case 4: fmt.Println(a/b)&lt;br /&gt;
        default: fmt.Println(“Invalid Operator”)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Arrays, Slices and Maps==&lt;br /&gt;
&lt;br /&gt;
*Arrays: Numbered sequence of elements starting with index zero and each of the elements having a fixed length. The example below illustrates various operations performed on arrays in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
&lt;br /&gt;
    var x[10] int&lt;br /&gt;
    x[99]=100&lt;br /&gt;
    fmt.Println(x)  //[0 0 ….. 0 100]&lt;br /&gt;
    fmt.Println(len(x)) //100&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Slices: &lt;br /&gt;
** It is a segment of an array.&lt;br /&gt;
** They have a length and are indexable.&lt;br /&gt;
**In case of a slice the size does not have to specified in the square bracket.&lt;br /&gt;
**Slices support two in-build functions: copy and append.&lt;br /&gt;
**The program below illustrates the different ways to create slices and use of copy and append.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main() {&lt;br /&gt;
    &lt;br /&gt;
    arr := [10] int {1,2,3,4,5,6,7,8,9,10}&lt;br /&gt;
    x := make([]int,10) // creates a slice [1...10]&lt;br /&gt;
    y := make([]int,10,10) //creates a slice [1...10]&lt;br /&gt;
    z := arr[0:10] //creates a slice [1...10]&lt;br /&gt;
    s1 := []int{1,2,3,4,5}&lt;br /&gt;
    s2 := append(s1, 6, 7)&lt;br /&gt;
    fmt.Println(s1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(s2) // [1,2,3,4,5,6,7]&lt;br /&gt;
    p1 := [] int{1,2,3,4,5}&lt;br /&gt;
    p2 :=make([]int, 4)&lt;br /&gt;
    copy(p2,p1)&lt;br /&gt;
    fmt.Println(p1) // [1,2,3,4,5]&lt;br /&gt;
    fmt.Println(p2)// [1,2,3,4]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Maps:&lt;br /&gt;
**A map is an unordered collection of key value pairs.&lt;br /&gt;
**Syntax: var x map[int] string , where int is the type of the key and string is the type of the value.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
    x := make(map[int]string)&lt;br /&gt;
    x[1] = one&lt;br /&gt;
    x[2] = two&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
&lt;br /&gt;
*In Go functions can take multiple inputs and return multiple outputs.&lt;br /&gt;
*Go supports a special kind of function called variadic function.&lt;br /&gt;
*Closure is the means by which functions can be created inside other function in Go.&lt;br /&gt;
*Go supports recursive functions.&lt;br /&gt;
*The example below the different types of function in Go.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
&lt;br /&gt;
    display(“Hello World”)&lt;br /&gt;
    sum :=calculateSum(10,20)&lt;br /&gt;
    v1,v2=multipleValues()&lt;br /&gt;
    p=product(5,10,20)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function without return type&lt;br /&gt;
func display( s string) {&lt;br /&gt;
    fmt.Println(s)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns a single value&lt;br /&gt;
func calculateSum(a int, b int) int {&lt;br /&gt;
    c: = a + b&lt;br /&gt;
    return c&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function which returns multiple values&lt;br /&gt;
func multipleValues(int, int) {&lt;br /&gt;
    return 1, 2&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Variadic function&lt;br /&gt;
func product(args ...int) int {&lt;br /&gt;
    p := 1&lt;br /&gt;
   for _, i := range args {&lt;br /&gt;
        p *= i&lt;br /&gt;
   }&lt;br /&gt;
   return p&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pointers==&lt;br /&gt;
It is used to reference a location in the memory where the value is stored rather than containing the value itself. Basic pointer operations in Go are illustrated in the example below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package main&lt;br /&gt;
&lt;br /&gt;
import “fmt”&lt;br /&gt;
&lt;br /&gt;
func main(){&lt;br /&gt;
    &lt;br /&gt;
//Different syntax for pointers&lt;br /&gt;
    &lt;br /&gt;
     ptr1 *int&lt;br /&gt;
     num :=10&lt;br /&gt;
     ptr1 = &amp;amp;num&lt;br /&gt;
     ptr2 := new(int)&lt;br /&gt;
     ptr2=&amp;amp;num&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Concurrency==&lt;br /&gt;
* Go ensures concurrency which allows sharing of state using communication mechanisms.&lt;br /&gt;
* Go provides support for multi&lt;br /&gt;
&lt;br /&gt;
=Users of Go=&lt;br /&gt;
Apart from Google, which uses Go programming for some of its development, companies like [http://en.wikipedia.org/wiki/Dropbox_(service) Dropbox], [http://en.wikipedia.org/wiki/CloudFlare CloudFlare], [http://en.wikipedia.org/wiki/SoundCloud SoundCloud], The BBC, Novartis, Cloud Foundry also use Go programming.  &lt;br /&gt;
Dropbox server (running in the cloud) and desktop client software were primarily written in [http://en.wikipedia.org/wiki/Python_(programming_language) Python]. From mid-2013 Dropbox began migrating its backend infrastructure to Go.&lt;br /&gt;
Some of the open-source applications that are using Go programming are Docker, Flynn, PaaS, Juju, nsq, Doozer e.t.c&lt;br /&gt;
&lt;br /&gt;
=Advantages=&lt;br /&gt;
 &lt;br /&gt;
C Level Performance -- golang is within a close margin of the performance level of C code (which is itself an extremely high performance language). It is certainly closer to the performance of native languages than other enterprise level languages such as Java, Scala, Erlang etc.&lt;br /&gt;
 &lt;br /&gt;
*'''Fast Compilation''' is one of the key advantages of Go language. The Golang compiler was designed to compile programs very quickly. Extremely large programs with massively high LOC counts compile seemingly instantly - after all, Golang was designed by Google to solve Google problems, and Google has big problems! At Google, code and CPU cores are both measured in the millions. Go provides a model for software construction that makes dependency analysis easy and avoids much of the overhead of C-style include files and libraries.&lt;br /&gt;
&lt;br /&gt;
Reduced compile time is a key improvement in the Go language&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      If A.go depends on B.go depends on C.go :&lt;br /&gt;
         Compile C.go, B.go then A.go normally (other languages)&lt;br /&gt;
         To compile A.go, compiler reads B.o not C.o (go)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At a large scale this should help in hugely speeding up&lt;br /&gt;
&lt;br /&gt;
Other advantages are      &lt;br /&gt;
* '''Concurrency Supported At Language Level'''. Concurrency is the ability to execute multiple computations simultaneously. In today's modern multicore and high-load computing environment, concurrency is a critical language feature, and one in which languages such as Java struggle immensely.&lt;br /&gt;
* By its design, Go proposes an approach for the construction of system software on '''multicore machines'''.&lt;br /&gt;
* Google have summed things up nicely with their motto: '''Don't communicate by sharing memory, share memory by communicating'''.Channels allow you to pass references to data structures between goroutines. If you consider this as passing around ownership of the data (the ability to read and write it), they become a powerful and expressive synchronization mechanism.  &lt;br /&gt;
* '''Go's type system has no hierarchy''', so no time is spent defining the relationships between types. Also, although Go has static types, the language attempts to make types feel lighter weight than in typical Object Oriented languages.&lt;br /&gt;
* '''Garbage Collection is much better'''. In C and C++, programmers spend a lot of time and energy on allocating and freeing memory. The designers of Go wanted to remove that complication, and ensure Go programmers could concentrate on more productive tasks. As such, they implemented garbage collection. As a developer, this is a very good thing. Sure, garbage collection comes with its own set of issues, but those are dealt with by the language implementer while the programmer is free to reap the other many benefits of Go.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
*Go is still an experimental language subject to change.&amp;lt;ref name = &amp;quot;Limitations1&amp;quot;&amp;gt;[http://stackoverflow.com/questions/2198529/what-are-the-advantages-and-disadvantages-of-go-programming-language stackoverflow]&amp;lt;/ref&amp;gt;&lt;br /&gt;
*Go's not very usable on Windows yet.&lt;br /&gt;
*The packages distributed with Go are pretty useful, but there are still some libraries you'll miss. Most notably a UI toolkit.&lt;br /&gt;
*There is no support for generics in Go, although there are many discussions around it.&lt;br /&gt;
*Confusing Semantics Of Exported Identifiers&amp;lt;ref name = &amp;quot;Limitations2&amp;quot;&amp;gt;&lt;br /&gt;
[https://functionwhatwhat.com/go’s-type-system-is-an-embarrassment functionwhatwhat ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hmarfat</name></author>
	</entry>
</feed>