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

Need to abstract the business logic from services in modules. #11

Open
nataneb32 opened this issue Sep 23, 2020 · 6 comments
Open

Need to abstract the business logic from services in modules. #11

nataneb32 opened this issue Sep 23, 2020 · 6 comments

Comments

@nataneb32
Copy link

nataneb32 commented Sep 23, 2020

You should use some file structure and separe, in modules, which implementation.

I would sujest to use pkg and cmd.

cmd/
  There is the clients, that consumes the application API.
pkg/
  There is the application with each module.

Example

cmd/
  cli/
    main.go
pkg/
  youtube/
    repo.go
  application/
    app.go
  video/
    video.go
    description.go
    interfaces.go
  

in the cmd/cli/main.go should be something like that.

package main

import (
  "module.org/pkg/application"
  "os"
)

func main() {
  application.run(os.Args)
}
@ArthurFleischman
Copy link
Contributor

You should use some file structure and separe, in modules, which implementation.

I would sujest to use pkg and cmd.

cmd/
  There is the clients, that consumes the application API.
pkg/
  There is the application with each module.

Example

cmd/
  cli/
    main.go
pkg/
  youtube/
    repo.go
  application/
    app.go
  video/
    video.go
    description.go
    interfaces.go
  

in the cmd/cli/main.go should be something like that.

package main

import (
  "../../pkg/application"
  "os"
)

func main() {
  application.run(os.Args)
}

Dont u use models package?

@ArthurFleischman
Copy link
Contributor

And why dont u use the full path to packages? (Cause ur using "../" paths)

@nataneb32
Copy link
Author

Yep. Using module is a lot better. I'm gonna edit it.

@nataneb32
Copy link
Author

You should use some file structure and separe, in modules, which implementation.
I would sujest to use pkg and cmd.

cmd/
  There is the clients, that consumes the application API.
pkg/
  There is the application with each module.

Example

cmd/
  cli/
    main.go
pkg/
  youtube/
    repo.go
  application/
    app.go
  video/
    video.go
    description.go
    interfaces.go
  

in the cmd/cli/main.go should be something like that.

package main

import (
  "../../pkg/application"
  "os"
)

func main() {
  application.run(os.Args)
}

Dont u use models package?

Inside the application.go and repository you use the model. But the main.go inside the web directory only consumes the application(application.go).

@nataneb32
Copy link
Author

It's a good pratice in Go. A lot of go projects use this structure.

@ArthurFleischman
Copy link
Contributor

It's a good pratice in Go. A lot of go projects use this structure.

Hmmm ill try it, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants