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

Update readme and november talk #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions 2018/11/how_not_rails_on_go/code/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package dao

//START OMIT
import "github.com/pkg/errors"

func A() {
_, err := B()
if err != nil {
errors.Wrap(err, "B failed")
}
// END OMIT
}

func B() (bytes []byte, error error) {
bytes = make([]byte, 0)
return
}
30 changes: 30 additions & 0 deletions 2018/11/how_not_rails_on_go/code/ginkgo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package user_test

import (
. "github.com/onsi/ginkgo"
"github.com/onsi/gomega"
"net/http"
)

var _ = Describe("your model behavior", func() {
BeforeEach(func() {
setUpModels()
setUpServices()
})
Context("Price Breakdown", func() {
Context("Price Breakdown", func() {
JustBeforeEach(func() {
result := getResultFromMock()
})
It("should return amount without currency", func() {
Ω(result).Should(BeEquivalentTo("200,50"))
})
})
})


// Ginkgo suite for a `tests` package
func TestAPI(t *testing.T) {
gomega.RegisterFailHandler(ginkgo.Fail)
ginkgo.RunSpecs(t, "API Suite")
}
27 changes: 27 additions & 0 deletions 2018/11/how_not_rails_on_go/code/package.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package dao
import (
"errors"
"fmt"
"time"

"github.com/astaxie/beego/validation"
"github.com/gtforge/order_locations_service/dto"
"github.com/gtforge/order_locations_service/models"
"github.com/gtforge/services_common_go/gett-storages"
"github.com/satori/go.uuid"
"github.com/gtforge/rides_api/models/location"
)
// START OMIT
package dao

func Find(uuid uuid.UUID) User, error {}

func FindLocations(uuid uuid.UUID) []location.Location, error { ... }
.
.
.

type ldao struct{}

func (t *ldao) Find(uuid uuid.UUID) []location.Location { ... }
// END OMIT
26 changes: 26 additions & 0 deletions 2018/11/how_not_rails_on_go/code/panic.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package dao

import "fmt"

//START OMIT
func f() {
defer func() {
if r := recover(); r != nil {
fmt.Println("Recovered in f", r)
}
}()
g(0)
// END OMIT
fmt.Println("Calling g.")
fmt.Println("Returned normally from g.")
}

func g(i int) {
if i > 3 {
fmt.Println("Panicking!")
panic(fmt.Sprintf("%v", i))
}
defer fmt.Println("Defer in g", i)
fmt.Println("Printing in g", i)
g(i + 1)
}
28 changes: 28 additions & 0 deletions 2018/11/how_not_rails_on_go/code/plain_sql.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package dao

import (
"database/sql"
"log"
"fmt"
"os/user"
)
// START OMIT
func Get(name string, age int) {
var db *sql.DB
rows, _ := db.Query("SELECT name, num, age " +
"FROM users WHERE age=? AND name = ?", age, name)
defer rows.Close()
for rows.Next() {
var user users.User
err := rows.Scan(&user.Name, &user.Num, &user.Age)
// END OMIT
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s is %d\n", name, age)
}
if err := rows.Err(); err != nil {
log.Fatal(err)
}

}
18 changes: 18 additions & 0 deletions 2018/11/how_not_rails_on_go/code/test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package model

import (
"github.com/stretchr/testify/assert"
"testing"
)

func TestSetting(t *testing.T) {
settings := SomeSettings{
Extra: 1,
Type: "text",
UnavailablePetaTextEnabled: false,
}

err := InsertUpdateSettings(settings)
assert.Equal(t, nil, err)

}
Binary file added 2018/11/how_not_rails_on_go/images/R-Ruby.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2018/11/how_not_rails_on_go/images/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2018/11/how_not_rails_on_go/images/gettGopher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2018/11/how_not_rails_on_go/images/gonode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2018/11/how_not_rails_on_go/images/hexagon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2018/11/how_not_rails_on_go/images/monolith.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2018/11/how_not_rails_on_go/images/newBeeApp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2018/11/how_not_rails_on_go/images/piglets.webm
Binary file not shown.
Binary file added 2018/11/how_not_rails_on_go/images/pigs.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2018/11/how_not_rails_on_go/images/redTrain.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2018/11/how_not_rails_on_go/images/rrbg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2018/11/how_not_rails_on_go/images/runBee.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading