Skip to content

Commit

Permalink
Minor modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
shijuvar committed Jun 20, 2021
1 parent b38f191 commit 2ffdd67
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 6 deletions.
48 changes: 48 additions & 0 deletions examples/generics/generic.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Run here: https://go2goplay.golang.org
package main

import (
"fmt"
)

//func sliceOf(type T)(elems ...T) []T {
// genSlice := []T{}
// for _, el := range elems {
// arr = append(arr, el)
// }
//
// return genSlice
//}
type Stringer interface {
ToString() string
}

type person struct {
Fname, Lname string
}

func (p person) ToString() string {
return fmt.Sprint(p.Fname, " ", p.Lname)
}

//func stringify(type T Stringer)(s []T) (ret []string) {
//for _, v := range s {
//ret = append(ret, v.ToString())
//}
//return ret
//}

func main() {
//strs := sliceOf("one", "two", "three", "four", "five")
//fmt.Println(strs)
//
//ints := sliceOf(1, 2, 3, 4, 5)
//fmt.Println(ints)
//p := []Stringer{
// person{"shiju", "varghese"},
// person{"irene", "rose"},
//}
//fmt.Println(p)
//s := stringify(p)
//fmt.Println(s)
}
Binary file added examples/http-app/cmd/appd/appd
Binary file not shown.
12 changes: 6 additions & 6 deletions examples/http/restapi/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ package main
import "time"

type note struct {
Id string `json:"id"`
Id string `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
CreatedOn time.Time `json:"createdon"`
}

// CRUD interface
type repository interface {
type repository interface {
create(note) error
update (string, note) error
delete (string) error
getById(string) (note,error)
update(string, note) error
delete(string) error
getById(string) (note, error)
getAll() ([]note, error)
}
}

0 comments on commit 2ffdd67

Please sign in to comment.