Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize echo backend project #436

Merged
merged 8 commits into from
Jan 30, 2025
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
28 changes: 28 additions & 0 deletions backend-go/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work
go.work.sum

# env file
.env

# bin
bin
23 changes: 23 additions & 0 deletions backend-go/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
run:
deadline: 5m

linters:
enable:
- errcheck
- goimports
- govet
- goconst
- gocyclo
- gofmt
- revive
- goprintffuncname
- gosec
- lll
- misspell
- nakedret
- wrapcheck
disable:
- gosimple
- staticcheck
- structcheck
- unused
28 changes: 28 additions & 0 deletions backend-go/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
CODEPAIR_VERSION := 0.2.0

default: help

tools: ## install tools for developing codepair
go install github.com/golangci/golangci-lint/cmd/[email protected]

build: ## builds an executable that runs in the current environment
go build -o ./bin/codepair ./cmd/codepair

fmt: ## applies format and simplify codes
go fmt ./...

lint: ## runs the golang-ci lint, checks for lint violations
golangci-lint run

test: ## run tests
go test -v ./...

clean: ## remove build artifacts
rm -rf ./bin

help:
@echo 'Commands:'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " %-20s %s\n", $$1, $$2}'
@echo

.PHONY: tools build fmt lint test clean help
27 changes: 27 additions & 0 deletions backend-go/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# CodePair Service Backend

This project is the backend part of the CodePair service developed using Go.
It is being migrated from the NestJS framework to Go. (Related Issue: [#430](https://github.com/yorkie-team/codepair/issues/430))

## Setting Developing Environment

### Requirements

Below are needed for developing and building CodePair.

- [Go](https://golang.org) (version 1.18+)

### Building & Testing

You can build the CodePair project by running the following command.

```sh
make tools
make build # executable: ./bin/codepair
```

You can automatically check the programmatic and stylistic errors of your code.

```sh
make lint
```
17 changes: 17 additions & 0 deletions backend-go/cmd/codepair/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package main

import (
"fmt"
"net/http"

"github.com/labstack/echo/v4"
)

func main() {
e := echo.New()
e.GET("/", func(c echo.Context) error {
err := c.String(http.StatusOK, "Hello, World!")
return fmt.Errorf("error: %w", err)
})
devleejb marked this conversation as resolved.
Show resolved Hide resolved
e.Logger.Fatal(e.Start(":3001"))
}
devleejb marked this conversation as resolved.
Show resolved Hide resolved
16 changes: 16 additions & 0 deletions backend-go/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module github.com/yorkie-team/codepair/backend

go 1.23.3

devleejb marked this conversation as resolved.
Show resolved Hide resolved
require (
github.com/labstack/echo/v4 v4.13.3 // indirect
github.com/labstack/gommon v0.4.2 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
)
23 changes: 23 additions & 0 deletions backend-go/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
github.com/labstack/echo/v4 v4.13.3 h1:pwhpCPrTl5qry5HRdM5FwdXnhXSLSY+WE+YQSeCaafY=
github.com/labstack/echo/v4 v4.13.3/go.mod h1:o90YNEeQWjDozo584l7AwhJMHN0bOC4tAfg+Xox9q5g=
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=