Git Product home page Git Product logo

rss-feed-aggregator's Introduction

rss-feed-aggregator

This repository contains a service written in GO for RSS(RDF Site Summary or Really Simple Syndication) feed aggregation.

Concepts Covered:

  • GO Lang
  • Postgres
  • Web-Server using CHI
  • Thunder Client extension of VSCode

Commands and packages used:

  • go mod init
  • go mod tidy
  • go mod vendor
  • go get github.com/go-chi/chi
  • go get github.com/go-chi/cors
  • go get github.com/google/uuid
  • go get github.com/joho/godotenv
  • go get github.com/lib/pq
brew install postgresql
brew services start postgresql
  • Download PGAdmin client to interact with Postgres Data-base.

  • Install sqlc: SQLC is an amazing Go program that generates Go code from SQL queries. It's not exactly an ORM, but rather a tool that makes working with raw SQL almost as easy as using an ORM.

go install github.com/kyleconroy/sqlc/cmd/sqlc@latest

  • Configure sqlc:
version: "2"
sql:
  - schema: "sql/schema"
    queries: "sql/queries"
    engine: "postgresql"
    gen:
      go:
        out: "internal/database"
  • Write an SQL query to be created as GO method/function: Inside the sql/queries directory, create a file called users.sql. Here is mine:
-- name: CreateUser :one
INSERT INTO users (id, created_at, updated_at, name)
VALUES ($1, $2, $3, $4)
RETURNING *;

$1, $2, $3, and $4 are parameters that we'll be able to pass into the query in our Go code. The :one at the end of the query name tells SQLC that we expect to get back a single row (the created user). Other keywords are :many, :exec(execute with void)

  • Run sqlc generate to generate new Go code for your queries.

  • Install goose: Goose is a database migration tool written in Go. It runs migrations from the same SQL files that SQLC uses, making the pair of tools a perfect fit.

go install github.com/pressly/goose/v3/cmd/goose@latest

A migration is a SQL file that describes a change to your database schema. For now, we need our first migration to create a users table. The simplest format for these files is:

number_name.sql For example, I created a file in sql/schema called 001_users.sql with the following contents:

-- +goose Up
CREATE TABLE ...

-- +goose Down
DROP TABLE users;

To run the migration:

goose postgres CONN up
ex: goose postgres postgres://<<username>>:<<password>>@<<address>>:<<port>>/<<db-name>> up

rss-feed-aggregator's People

Contributors

syedaanif avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.