This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace articles; | |
table Image { | |
url: string ; | |
mime : string ; | |
width : int ; | |
height : int ; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import: | |
- package: github.com/stretchr/testify | |
version: ^1.1.4 | |
- package: github.com/go-sql-driver/mysql | |
version: ^1.3.0 | |
- package: github.com/arielizuardi/envase | |
version: v0.2.1 | |
- package: github.com/docker/docker | |
version: v17.05.0-ce-rc3 | |
subpackages: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/bxcodec/faker" | |
) | |
type SomeStruct struct { | |
Int int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestGetByID(t *testing.T) { | |
db, mock, err := sqlmock.New() | |
if err != nil { | |
t.Fatalf("an error '%s' was not expected when opening a stub database connection", err) | |
} | |
defer db.Close() | |
rows := sqlmock.NewRows([]string{"id", "title", "content", "updated_at", "created_at"}). | |
AddRow(1, "title 1", "Content 1", time.Now(), time.Now()) | |
query := "SELECT id,title,content,updated_at, created_at FROM article WHERE ID = \\?" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestGetByID(t *testing.T) { | |
var mockArticle models.Article | |
err := faker.FakeData(&mockArticle) | |
assert.NoError(t, err) | |
mockUCase := new(mocks.ArticleUsecase) | |
num := int(mockArticle.ID) | |
mockUCase.On("GetByID", int64(num)).Return(&mockArticle, nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Post struct { | |
// db tag lets you specify the column name if it differs from the struct field | |
Id int64 `db:"post_id"` | |
Created int64 | |
Title string `form:"Title" binding:"required"` | |
Body string `form:"Body"` | |
UserId int64 `form:"UserId"` | |
Url string | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Server API for ArticleHandler service | |
type ArticleHandlerServer interface { | |
GetArticle(context.Context, *SingleRequest) (*Article, error) | |
FetchArticle(*FetchRequest, ArticleHandler_FetchArticleServer) error | |
GetListArticle(context.Context, *FetchRequest) (*ListArticle, error) | |
UpdateArticle(context.Context, *Article) (*Article, error) | |
Delete(context.Context, *SingleRequest) (*DeleteResponse, error) | |
Store(context.Context, *Article) (*Article, error) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
func main { | |
dbHost := config.GetString(`database.host`) | |
dbPort := config.GetString(`database.port`) | |
dbUser := config.GetString(`database.user`) | |
dbPass := config.GetString(`database.pass`) | |
dbName := config.GetString(`database.name`) | |
connection := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s", dbUser, dbPass, dbHost, dbPort, dbName) | |
val := url.Values{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
conn, err := grpc.Dial("localhost:8080", grpc.WithInsecure()) | |
if err != nil { | |
fmt.Println("Unexpected Error", err) | |
} | |
defer conn.Close() | |
// CALL the NewArticleHandlerClient from generated File | |
c := article.NewArticleHandlerClient(conn) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package article | |
import ( | |
"github.com/bxcodec/go-clean-arch-grpc/models" | |
"github.com/bxcodec/go-clean-arch-grpc/usecase" | |
) | |
type server struct { | |
usecase usecase.ArticleUsecase | |
} |