add package structure example

This commit is contained in:
Aliberk Sandıkçı 2023-07-24 10:22:51 +03:00
parent d937c0497a
commit 016b14ac21
Signed by: asandikci
GPG key ID: 25C67A03B5666BC1
4 changed files with 36 additions and 8 deletions

View file

@ -1,15 +1,18 @@
# go-organization
Understand project structure of GO. Go Modules, GOPATH, efficent development environment...
Understand project structure of GO. Go Modules, GOPATH, efficent development environment... This repo contains lots of trash folder/file! Just trying to understand structure with trying lots of unnecessary things too
### Base Resources
- https://github.com/golang/go/wiki/Modules
- https://go.dev/blog/using-go-modules
- https://github.com/golang-standards/project-layout
- https://go.dev/doc/code
- https://tutorialedge.net/golang/go-project-structure-best-practices/
- https://www.digitalocean.com/community/tutorials/how-to-use-go-modules
- https://go.dev/ref/mod
| Resource | Explanation | Implementation |
| -------- | ----------- | -------------- |
| https://github.com/golang/go/wiki/Modules | - | - |
| https://go.dev/blog/using-go-modules | - | - |
| https://github.com/golang-standards/project-layout | - | - |
| https://go.dev/doc/code | - | - |
| https://tutorialedge.net/golang/go-project-structure-best-practices/ | - | - |
| https://www.digitalocean.com/community/tutorials/how-to-use-go-modules | Modules | - |
| https://www.digitalocean.com/community/tutorials/how-to-write-packages-in-go | Packages | [package-str](simple-structure/package-str/) |
| https://go.dev/ref/mod | - | - |
### FAQ
<details>

3
simple-structure/go.mod Normal file
View file

@ -0,0 +1,3 @@
module Liderahenk/go-organization/simple-structure
go 1.20

View file

@ -0,0 +1,12 @@
package main
import (
"Liderahenk/go-organization/simple-structure/package-str/great"
"fmt"
)
func main() {
great.Hello()
fmt.Println(great.Name)
// fmt.Println(great.name2) // ERROR lowercase variables cannot be used outside of package itself
}

View file

@ -0,0 +1,10 @@
package great
import "fmt"
var Name = "deniz"
var name2 = "deniz2"
func Hello() {
fmt.Println("Hello World (go-organization/simple-structure/package-str/great/great.go)")
}