【Go Programming Learning】Introduction to Go

Environment configuration

1. Go installation package:
download address: https://studygolang.com/dl
2. IDE: GoLand
download address: https://blog.jetbrains.com/go/

GoLand only needs to add the path of the go installation, use the installed go environment to compile without installing any additional plug-ins

Go language features

  • Automatic garbage collection
  • Richer built-in types
  • Function multiple return values
  • Error handling
  • Anonymous functions and closures
  • Type and interface
  • Concurrent programming
  • reflection
  • Language interactivity

Getting to know the Go program

code

package main

import "fmt"

func main(){
    
    
	fmt.println("Hello World!")
}

Procedure description

  • Language structure: package declaration introduces package function variable statement & expression comment
  • The first line defines a package. All Go source program files must have a package declaration statement at the head. Go manages the namespace through the package
  • The third line refers to an external package fmt (standard input/output package). The referenced package can be a standard library package, or a third-party or custom package
  • The func keyword declares the function main, and main represents the entry function of the Go program

Source code characteristics

  • Suffix .go
  • The source program defaults to UTF-8 encoding
  • The semicolon at the end of the statement can be omitted
  • The "{" at the beginning of the function body must be at the end of the line where the function head is located, and cannot be a separate line
  • The package name of the main function must be main

Guess you like

Origin blog.csdn.net/i0o0iW/article/details/111164024