Skip to content

Commit

Permalink
GO-0001: init zoo
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr Matkovskyi committed Sep 11, 2023
1 parent bbd35c1 commit 69794dc
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module structs

go 1.21.0
go 1.21.1
10 changes: 8 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package main

import (
"fmt"
"structs/zoo"
)

/*
0. Declaration
1. Different types
Expand All @@ -19,7 +24,8 @@ package main
16. Assignment
*/



func main() {
fmt.Printf("On duty today: %s, with %d years of experience\n", zoo.Mihalich.Name, zoo.Mihalich.Experience)
fmt.Printf("In the program there is a %s named: %s. It has %d lags", zoo.Spider.Kind, zoo.Spider.Name, zoo.Spider.Number_of_legs)

}
7 changes: 7 additions & 0 deletions structs/0_declaration.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ type user struct {
Age int
}

type User struct {
// Contains different field names with different types
Name string
Surname string
Age int
}

// Public struct
type Post struct {
// Public field
Expand Down
25 changes: 25 additions & 0 deletions zoo/zoo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package zoo

// Private struct, visible inside this package only
type zookeeper struct {
// Contains different field names with different types
Name string
Surname string
Age int
Experience int
}

type animal struct {
Kind string
Name string
Number_of_legs int
}

type cage struct {
Size string
Color string
Number int
}

var Mihalich = zookeeper{"Mihail", "Ivanov", 56, 30}
var Spider = animal{Kind: "spider", Name: "Gora", Number_of_legs: 8}

0 comments on commit 69794dc

Please sign in to comment.