Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
16 changes: 16 additions & 0 deletions c.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
mode: set
Assignment/main.go:7.13,9.2 1 0
Assignment/day-4/main.go:14.39,16.2 1 0
Assignment/day-4/main.go:19.47,20.17 1 0
Assignment/day-4/main.go:20.17,23.3 2 0
Assignment/day-4/main.go:24.2,25.65 2 0
Assignment/day-4/main.go:29.48,30.24 1 0
Assignment/day-4/main.go:30.24,33.3 2 0
Assignment/day-4/main.go:34.2,35.66 2 0
Assignment/day-4/main.go:38.13,45.6 5 0
Assignment/day-4/main.go:45.6,54.17 8 0
Assignment/day-4/main.go:55.10,56.28 1 0
Assignment/day-4/main.go:57.10,61.27 4 0
Assignment/day-4/main.go:62.10,66.28 4 0
Assignment/day-4/main.go:67.10,69.10 2 0
Assignment/day-4/main.go:70.11,71.55 1 0
175 changes: 175 additions & 0 deletions day-16_gofr/3layerarch/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
version: "2"
linters:
default: none
enable:
- asciicheck
- bodyclose
- canonicalheader
- copyloopvar
- dogsled
- dupl
- err113
- errcheck
- errorlint
- exhaustive
- funlen
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocritic
- gocyclo
- godot
- goprintffuncname
- gosec
- govet
- ineffassign
- lll
- mirror
- misspell
- mnd
- nakedret
- nestif
- noctx
- nolintlint
- prealloc
- revive
- rowserrcheck
- staticcheck
- testifylint
- thelper
- unconvert
- unparam
- unused
- usestdlibvars
- usetesting
- whitespace
- wsl

# don't enable:
# - godox # Disabling because we need TODO lines at this stage of project.
# - testpackage # We also need to do unit test for unexported functions. And adding _internal in all files is cumbersome.

settings:
dupl:
threshold: 100
exhaustive:
default-signifies-exhaustive: false
funlen:
lines: 100
statements: 50
goconst:
min-len: 2
min-occurrences: 2
gocritic:
disabled-checks:
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- octalLiteral
- whyNoLint
- wrapperFunc
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
gocyclo:
min-complexity: 10
govet:
enable:
- shadow
settings:
printf:
funcs:
- (gofr.dev/pkg/gofr/Logger).Logf
- (gofr.dev/pkg/gofr/Logger).Errorf
lll:
line-length: 140
misspell:
locale: US
mnd:
checks:
- argument
- case
- condition
- return
nolintlint:
require-explanation: true # require an explanation for nolint directives
require-specific: true # require nolint directives to be specific about which linter is being skipped
allow-unused: false # report any unused nolint directives
revive:
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: empty-block
- name: error-naming
- name: error-return
- name: error-strings
- name: errorf
- name: exported
arguments:
# enables checking public methods of private types
- checkPrivateReceivers
# make error messages clearer
- sayRepetitiveInsteadOfStutters
- name: increment-decrement
- name: indent-error-flow
- name: range
- name: receiver-naming
- name: redefines-builtin-id
- name: superfluous-else
- name: time-naming
- name: unexported-return
- name: unreachable-code
- name: unused-parameter
- name: var-declaration
- name: var-naming
- name: bare-return
- name: bool-literal-in-expr
- name: comment-spacings
- name: early-return
- name: defer
- name: deep-exit
- name: unused-receiver
- name: use-any
staticcheck:
checks:
- all
- -QF1001 # TODO remove this line and fix reported errors
- -QF1003 # TODO remove this line and fix reported errors
- -QF1008 # TODO remove this line and fix reported errors
- -ST1000 # TODO remove this line and fix reported errors
usestdlibvars:
time-layout: true
exclusions:
presets:
- common-false-positives # TODO fix errors reported by this and remove this line
- legacy # TODO fix errors reported by this and remove this line
- std-error-handling # TODO remove this line, configure errcheck, and fix reported errors
rules:
- linters:
- dupl
- goconst
- mnd
path: _test\.go
- linters:
- revive
text: "exported (.+) should have comment" # TODO fix errors reported by this and remove this line
paths:
- examples # TODO remove this line and fix reported errors
formatters:
enable:
- gci
- gofmt
settings:
gci:
sections:
- standard
- default
- localmodule
goimports:
local-prefixes:
- github.com/golangci/golangci-lint
8 changes: 8 additions & 0 deletions day-16_gofr/3layerarch/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions day-16_gofr/3layerarch/.idea/3layerarch.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions day-16_gofr/3layerarch/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions day-16_gofr/3layerarch/c.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
mode: set
3layerarch/datasource/sql.go:7.41,9.16 2 0
3layerarch/datasource/sql.go:9.16,11.3 1 0
3layerarch/datasource/sql.go:13.2,15.16 2 0
3layerarch/datasource/sql.go:15.16,17.3 1 0
3layerarch/datasource/sql.go:20.2,26.16 2 0
3layerarch/datasource/sql.go:26.16,28.3 1 0
3layerarch/datasource/sql.go:31.2,35.16 2 0
3layerarch/datasource/sql.go:35.16,37.3 1 0
3layerarch/datasource/sql.go:39.2,39.16 1 0
3layerarch/docs/docs.go:302.13,304.2 1 0
10 changes: 10 additions & 0 deletions day-16_gofr/3layerarch/configs/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
APP_NAME=test-service
HTTP_PORT=8080

DB_HOST=localhost
DB_USER=root
DB_PASSWORD=root123
DB_NAME=test_db
DB_PORT=3306
DB_DIALECT=mysql
METRICS_PORT=9999
40 changes: 40 additions & 0 deletions day-16_gofr/3layerarch/datasource/sql.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package datasource

import (
"database/sql"
)

func New(creds string) (*sql.DB, error) {
db, err := sql.Open("mysql", creds)
if err != nil {
return nil, err
}

err = db.Ping()

if err != nil {
return nil, err
}

// Ensure TASKS table exists
_, err = db.Exec(`CREATE TABLE IF NOT EXISTS TASKS (
id INT AUTO_INCREMENT PRIMARY KEY,
task TEXT,
completed BOOL DEFAULT FALSE,
user_id int
);`)
if err != nil {
return nil, err
}

// Ensure USERS table exists
_, err = db.Exec(`CREATE TABLE IF NOT EXISTS USERS (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100)
);`)
if err != nil {
return nil, err
}

return db, nil
}
Loading