Is go language a programming language?

青灯夜游
Release: 2022-12-01 19:14:58
Original
2475 people have browsed it

Go language is a programming language. The go language, also known as Golang, is a statically strongly typed, compiled, concurrent programming language with garbage collection capabilities developed by Google. The launch of the Go language aims to reduce the complexity of the code without losing application performance. It has the advantages of "simple deployment, good concurrency, good language design, and good execution performance".

Is go language a programming language?

The operating environment of this tutorial: Windows 7 system, GO version 1.18, Dell G3 computer.

Go (also known as Golang) is a statically strongly typed, compiled, concurrent programming language with garbage collection capabilities developed by Google's Robert Griesemer, Rob Pike and Ken Thompson. The Go language syntax is similar to C, but its functions include: memory safety, GC (garbage collection), structural form and CSP-style concurrent computing.

The Go language (or Golang) originated in 2007 and was officially released in 2009. Go is a very young language, and its main goal is to "have both the development speed of dynamic languages ​​such as Python and the performance and security of compiled languages ​​such as C/C."

Go language is another attempt at programming language design and a major improvement over C-like languages. It not only allows you to access the underlying operating system, but also provides powerful network programming and concurrent programming support. Go language has many uses and can be used for network programming, system programming, concurrent programming, and distributed programming.

The launch of Go language aims to reduce the complexity of the code without losing application performance. It has the advantages of "simple deployment, good concurrency, good language design, and good execution performance". Currently, many domestic IT companies have adopted Go language to develop projects.

Features

Computer software has experienced decades of development and has formed a variety of academic schools, including process-oriented programming, object-oriented programming, functional programming, Regarding message-oriented programming, etc., there are different opinions on which of these ideas is better or worse.

In addition to OOP, some niche programming philosophies have emerged in recent years, and the Go language has also absorbed these ideas. For example, the Go language accepts some ideas from functional programming and supports anonymous functions and closures. For another example, the Go language has accepted the message-oriented programming ideas represented by the Erlang language, supports goroutines and channels, and recommends using messages instead of shared memory for concurrent programming. Overall, the Go language is a very modern language, small but very powerful.

The most important features of Go language:

  • Automatic garbage collection
  • More abundant built-in types
  • Multiple return values ​​for functions
  • Error handling
  • Anonymous functions and closures
  • Types and interfaces
  • Concurrent programming
  • Reflection
  • Language interactivity

Go language purpose

The Go language is designed to be used on giant central servers equipped with Web servers, storage clusters or similar purposes Systems programming language.

For the field of high-performance distributed systems, Go language undoubtedly has higher development efficiency than most other languages. It provides massive parallel support, which is perfect for game server development.

Supported platform

Hardware architecture

Go language design supports mainstream 32-bit and 64-bit x86 platforms. Also supports 32-bit ARM architecture.

Operating system

The Go language supports Windows, Apple Mac OS X, Linux and FreeBSD operating systems on the Go1 version.

Development tools

LiteIDE is a cross-platform lightweight integrated development environment (IDE) specially developed for the Go language, developed by QT write.

Main Features:

  • Supports mainstream operating systems: Windows, Linux, MacOS X.

  • Go compilation environment management and switching: manage and switch multiple Go compilation environments, and support Go language cross-compilation.

  • Project management method consistent with Go standards: GOPATH-based package browser, GOPATH-based compilation system, GOPATH-based Api document retrieval.

  • Go language editing support: class browser and outline display, perfect support for Gocode (code automatic completion tool), Go language document viewing and API quick retrieval, code expression information display F1, source code definition jump supports F2, Gdb breakpoint and debugging support, gofmt automatic formatting support.

  • Other features: Support multi-language interface display, complete plug-in architecture, support editor color scheme, Kate-based grammar display support, full-text word auto-completion, support keyboard shortcuts Binding solution, Markdown document editing support, real-time preview and synchronous display, customized CSS display, export of HTML and PDF documents, batch conversion/merging into HTML/PDF documents

Sublime Text 3 (hereinafter referred to as Sublime) GoSublime gocode MarGo combination.

Its advantages include:

  • Automated prompt code.

  • Automatically format the code when saving, making the code you write more beautiful and in line with Go standards.

  • Support project management

  • Support syntax highlighting

Vim It is a text editor developed from vi and enjoys the title of "God of Editors". It is particularly rich in functions that facilitate programming, such as code completion, compilation, and error jumping, and is widely used among programmers.

Emacs is a text editor developed by the GNU open source organization. It is also an integrated environment. It was once jokingly called "an operating system disguised as an editor."

Eclipse is also a very commonly used development tool. You can use Eclipse to write Go programs.

Goland is an integrated development environment specifically for the Go language. It has now become a paid software.

Example

Next we will write the first Go program hello.go (The extension of the Go language source file is .go) , the code is as follows:

hello.go file

package main
 
import "fmt"
 
func main() {
    fmt.Println("Hello, World!")
}
Copy after login

To execute Go language code, you can use the go run command.

Execute the above code output:

$ go run hello.go 
Hello, World!
Copy after login

In addition, we can also use the go build command to generate binary files:

$ go build hello.go 
$ ls
hello    hello.go
$ ./hello 
Hello, World!
Copy after login

Go language environment installation

Go language supports the following systems:

  • Linux
  • FreeBSD
  • Mac OS X (also known as Darwin)
  • Windows

The installation package download address is: https://golang.org/dl/

If you cannot open it, you can use this address: Downloads - The Go Programming Language.

The package name corresponding to each system:

Operating system Package name
Windows go1.4.windows-amd64.msi
Linux go1.4.linux-amd64.tar.gz
Mac go1.4.darwin-amd64-osx10.8.pkg
FreeBSD go1.4 .freebsd-amd64.tar.gz


##UNIX/Linux/Mac OS X, and FreeBSD installation

The following introduces the source code installation method under UNIX/Linux/Mac OS X, and FreeBSD systems:

1. Download the binary package: go1.4 .linux-amd64.tar.gz.

2. Unzip the downloaded binary package to the /usr/local directory.

tar -C /usr/local -xzf go1.4.linux-amd64.tar.gz
Copy after login
3. Add the /usr/local/go/bin directory to the PATH environment variable:

export PATH=$PATH:/usr/local/go/bin
Copy after login
Copy after login
The above can only temporarily add PATH. Close the terminal and log in again and it will disappear.

We can edit ~/.bash_profile or /etc/profile and add the following command to the end of the file, so that it will take effect permanently:

export PATH=$PATH:/usr/local/go/bin
Copy after login
Copy after login
You need to execute it after adding:

source ~/.bash_profile
或
source /etc/profile
Copy after login

Note: Under MAC system, you can use the installation package ending with .pkg to directly double-click to complete the installation. The installation directory is /usr/local/ go/ Next.


Installation under Windows system

You can use the .msi suffix under Windows (the file can be found in the download list , such as go1.4.2.windows-amd64.msi) installation package to install.

By default the

.msi file will be installed in the c:\Go directory. You can add the c:\Go\bin directory to the Path environment variable. After adding it, you need to restart the command window for it to take effect.

Installation Test

Create working directory

C:\>Go_WorkSpace.

test.go file code:

package main

import "fmt"

func main() {
   fmt.Println("Hello, World!")
}
Copy after login
Use the go command to execute the above code and the output result is as follows:

C:\Go_WorkSpace>go run test.go

Hello, World!
Copy after login
[Related recommendations:

Go video tutorial]

The above is the detailed content of Is go language a programming language?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template