How to Build, install and run Go Programs in Windows - GoLang 1.20

Channel:
Subscribers:
5,740
Published on ● Video Link: https://www.youtube.com/watch?v=EDEvW-_efBw



Category:
Tutorial
Duration: 6:09
13 views
0


In this video we are going to show how to build, install and run golang programs in Windows Environment.

Below are steps involved.

I will be creating one new directory called "GoExamples2" where I am going to place .go files.

Now I am copying one go program which has main() function i.e. i am going to copy one standalone go program.
This program contains the logic to connect to oracle database 12c and fetch the records of person table.

Next open the command prompt and go to D:\GoExamples2 directory and initialize or create the go.mod file using (go mod init).
creating the go.mod file is mandatory if you want to build and install your application.

Now I am going to download and install the third party modules using "go get" command.
These modules entries are added to go.mod file and it will be used by the go program which i have shown.
we can see the downloaded modules here C:\Users\RAMANATHAN\go

Now I am going to execute the "go build" command which will compile packages and dependencies.
Which means it will create one .exe file (in windows) same as module name.
Here the module name is oracle12c (you can see the module name in go.mod file). so .exe file will be created as oracle12c.exe.
Now we can see I can able to run the exe simply typing the name oracle12c.exe.

Now I am going to customize the .exe file name i.e. give my own name for .exe instead of module name using the command "go build -o".

Now I am going to show you some basic environment variables GOPATH and GOROOT
GOPATH is ---- C:\Users\USERNAME\go here it is C:\Users\RAMANATHAN\go which contains all the downloaded modules and packages.
GOROOT is ---- C:\Go-1.20 which is GoLang Binary (Go Software) installation directory.

Now I am going to execute "go install" command which will compiles and installs the packages named by the import paths.
Once you executed this command .exe file will be generated and copied to C:\Users\RAMANATHAN\go\bin directory.
That .exe file name will be same like module name.

We can execute that exe anywhere now.

If you want to uninstall the .exe simply delete the file in bin directory. Here i am deleting entire bin directory as i am having only one file.

These are the basic steps to Build, install and run Go Programs in Windows.

#go #goprogramming #golang #golangtutorial #golanguage #golangwindows #gowindows




Other Videos By java frm


2023-04-18How to create struct with fields that contain only a type without the field name in GoLang 1.20
2023-04-18How to add elements to map in GoLang 1.20
2023-04-18How to access and modify individual fields of struct in GoLang 1.20
2023-04-18How to access individual runes using for range loop in GoLang 1.20
2023-04-18How to access individual characters of string using for range loop in GoLang 1.20
2023-04-18How to access and print individual bytes of string in GoLang 1.20
2023-04-18How to connect GoLang to Oracle Database 23c in Windows - Go Oracle Database connectivity - godror
2023-04-18How to connect GoLang to Oracle Database 19c in Windows - Go Oracle Database connectivity - godror
2023-04-18How to connect GoLang to Oracle Database 12c in Windows - Go Oracle Database connectivity - godror
2023-04-18How to remove the entire module download cache in GoLang for Windows - GoLang 1.20
2023-04-18How to Build, install and run Go Programs in Windows - GoLang 1.20
2023-04-15How to install golang 1.20 on Windows 11 from zip archive - GO 1.20 installation on Windows
2023-04-15How to install golang 1.20 on Rocky Linux 8 from zip archive - GO 1.20 installation on linux
2023-04-15How to install golang 1.20 on Red Hat Enterprise Linux 8 from zip - GO 1.20 installation on linux
2023-04-15How to install golang 1.20 on Oracle Linux 8 from zip archive - GO 1.20 installation on linux
2023-04-15How to install golang 1.20 on AlmaLinux 8 from zip archive - GO 1.20 installation on linux
2023-04-15How to install golang 1.19 on Windows 11 from zip archive - GO 1.19 installation on Windows
2023-04-15How to install golang 1.19 on Rocky Linux 8 from zip archive - GO 1.19 installation on linux
2023-04-15How to install golang 1.19 on Red Hat Enterprise Linux 8 from zip - GO 1.19 installation on linux
2023-04-15How to install golang 1.19 on Oracle Linux 8 from zip archive - GO 1.19 installation on linux
2023-04-15How to install golang 1.19 on AlmaLinux 8 from zip archive - GO 1.19 installation on linux



Tags:
how to compile and run go program in windows
how to build and install go program in windows
how to build go program in windows
how to install go program in windows
howw to create go module
golang build command
golang install command
go build
go install
go mod init
go get
go.mod file
build go module
golang tutorial
golang projects
go programming course
learn go
how to run go program
golang videos
howto
go1.20
golang 1.20 windows
go programming in windows