GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — scripts/intro_to_go.txt at main · cyclone-github/scripts

Expand file tree

/

intro_to_go.txt

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
41 lines (38 loc) · 2.03 KB
/

intro_to_go.txt

Copy path

File metadata and controls

41 lines (38 loc) · 2.03 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Intro to Go source code and compiling
Let's assume you know what Go is and why you want to use it.
1. Install Go
If using Linux, simply run my Go install script (works on amd/arm 32/64 bit *nix):
https://github.com/cyclone-github/scripts/blob/main/install_go.sh
If you want to manually install Go on Linux / Windows / Mac, follow the official directions here:
https://go.dev/doc/install
Confirm Go is working by running "go version" from terminal / cmd.
2. Run Go Source Code (to test before compiling)
Run these commands from terminal / cmd from the directory that contains your *.go source code.
If “main.go” is your source code file:
go mod init main.go
go mod tidy
For single *.go file:
go run main.go
For multiple *.go files:
go run .
3. Compile Go Source Code
If using Linux, you can use my shell script to download dependencies and x-compile source code for Linux, Windows or Mac.
Take a look at the script and comment out any options you don't need. Once the script has completed, your new binaries will be in the newly created bin/ directory within your current directory.
https://github.com/cyclone-github/scripts/blob/main/go_compiler.sh
To manually compile Go source code, run these commands from terminal / cmd from the directory that contains your *.go source code.
If “main.go” is your source code file:
go mod init main.go
go mod tidy
For single *.go file:
go build main.go
For multiple *.go files:
go build .
>or<
go build -ldflags="-s -w" main.go (-ldflags="-s -w" omits symbol table and debug information, making the binary smaller)
go build -ldflags="-s -w" . <--- for multi-source file program
On linux, I like to run strip to remove debug info & upx to compress the binary. My shell script above automatically does this, but you can run these commands manually as well.
If “main.bin” is your binary file:
strip main.bin
upx main.bin
Note: compressing Go binaries with upx can cause false positives on some anti-virus programs, especially on Windows (exe) binaries.
More info on false positives with Go binaries: https://go.dev/doc/faq#virus
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.