Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the necessary knowledge to learn GO programming?

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the necessary knowledge of learning GO programming, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

1. Environment variables:

Use go env to view environment variables

GOARCH/GOHOSTARCH: architecture, amd64 or 386

GOOS/GOHOSTOS: operating system, linux or windows

GOROOT: GO installation directory

GOBIN: GO program directory

GOTOOLDIR: GO tool catalog

CGO_ENABLED: whether to enable CGO

CC

CXX

GOGCCFLAGS

GORACE: data synchronization detection, with go test, go run, go build, go install-race option.

GOPATH: GO package lookup path

two。 Code organization:

-$GOPATH contains multiple workspace

-workspace contains src, pkg, bin

-src contains package, namely program, library

-package contains go file

Need to understand:

* package name vs package path

Package name refers to the identifie. Package name declared with package in go file. Package path refers to the path relative to GOPATH. Same package path, same package name.

Package import complete syntax:

Import [name] "path"

Where:

The name part can

None, using the default name declared by package

Point, using the current package

Blank, execute init only

Name, custom name

The path part can

Absolute path: the path relative to $GOPATH

Relative path: the path relative to the current file.

Note: there can be no relative paths using the vendor mechanism, otherwise the parsing error will occur.

* program vs library

Package name represents program for main

Package name is not main for library

3. Code testing

Execute the test code using the go test command.

Test file is suffixed with _ test.

Test func is prefixed with Test.

4. Remote packet

Use the go get command to get the remote package.

However, the go test command relies on git or svn.

Thank you for reading this article carefully. I hope the article "what is necessary to learn GO programming" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report