GoLang Setup with PostgreSQL + Hello World project

Опубликовано: 04 Октябрь 2024
на канале: Ajinkya X
11,941
106

Setup #GOLang, #PostgreSQL and #GORM on MAC with brew + Setup vscode editor.

@4:03 In this video we will learn to Install GO Lang on your system. As well we will do a test connection to PostgreSQL Database.

@8:02 We will as well learn to Install Postgres with BREW on mac. And setup a datalayer with GORM (GORM is an ORM library for Golang, aims to be developer friendly).


Open subl ~/.zshrc

export GOPATH=~/projects/GO_PROJECTS
export PATH=$PATH:$GOPATH/bin:$PATH

=======================================================

-- Install up Postgres + GORM with brew

Assuming you already have BREW installed.

Type following in your terminal:
brew update
brew install postgresql


=======================================================


Setup Database layer
```bash
go get github.com/lib/pq
go get github.com/jinzhu/gorm
```

Setup Postgresql & Start Service
```bash
brew install Postgresql
pg_ctl -D /usr/local/var/postgres start
pg_ctl -D /usr/local/var/postgres stop
```

*Optional get `https://eggerapps.at/postico/` GUI client

=======================================================

How to view Postgresql Info
```bash
psql postgres
CREATE DATABASE gorm;
```

`\du` shows Database users
`\password ajinkyaborade`
and then set a password

-- https://github.com/jinzhu/gorm
-- https://github.com/go-pg/pg
-- https://formulae.brew.sh/formula/post...
-- https://eggerapps.at/postico/

=======================================================