Git Product home page Git Product logo

gotraining's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gotraining's Issues

Any Example for Event Based Architecture

Hi, I am taking your course from O'Rielly, We are developing Event based Microservices Architecture using Golang,

Any suggestion for Architecture Example With Golang(Micro-services)+Kafka?

Remove println

Let's get rid of all usages of println and use the fmt versions. I have students copying and pasting from the examples that use it.

Are there any reasons to keep it in any examples? Like in the escape analysis code or something?

Compile and lint issues

I was trying to use gorename from VSCode the other day, but was blocked by some code in my GOPATH that turned out to be in the gotraining repo. Now, I updated the repo and the problem went away, but even after updating it appears there are still some compile and lint issues that you may want to take care of:

% golint ./...
2017/09/04 10:00:32 topics/go/language/methods/example5/example5.go:4:1: expected 'package', found 'import' (and 1 more errors)
main.go:17:5: exported var Render should have comment or be unexported
topics/go/concurrency/channels/example5/example5.go:18:7: var timeoutSeconds is of type time.Duration; don't use unit-specific suffix "Seconds"
topics/go/design/composition/exercises/template1/template1.go:109:6: expected operand, found '{' (and 1 more errors)
topics/go/design/error_handling/example1/example1.go:24:1: comment on exported function New should be of the form "New ..."
topics/go/design/error_handling/example1/example1.go:26:23: exported func New returns unexported type main.error, which can be annoying to use
topics/go/language/exporting/example3/counters/counters.go:12:21: exported func New returns unexported type counters.alertCounter, which can be annoying to use
topics/go/packages/context/exercises/template1/template1.go:71:3: expected '}', found 'return' (and 1 more errors)

Additional Book

I very much liked "Get Programming with Go"; but I found "Head First Go" (O'Reilly) even better; maybe you add it to the list?

slice.Min() and slice.Max() don't account for nil or empty slices

maybe this complicates things but i think slice.Max() and slice.Min() should return an error.

there is no good way to return a value that is out of band (like -1 nor is there a NaN like with floats).

so the best way to signal an error like a nil or empty slice is via an error value.

the result is that if you pass a nil or empty slice, we immediately access an element in our slice that is out of bounds when we prime our max value.

also, i feel like the functions have a more general path -- instead having to check if the supplied slice has only 1 element, we can check if we're working on our first iteration in the inner loop by having range return the index.

Could the `Hardcore Go` program be renamed?

Hardcore is a word associated with porn; although I'm sure it attracts some people, it alienates others. A new name might convey the rigor and thoroughness of the program, and also avoid images of violence and misogyny.

If the organizers and community are happy with the name, I'll close this issue. But I know people in the community who would like to create a more inclusive culture, and this could be a good step in that direction.

Project no longer go gettable after dep init

When dep was last ran against the project, it pulled in v1.1.0 of github.com/theplant/blackfriday which is broken (bad import for unicode/utf8). We should tweak the Gopkg.toml file to pull a good version, and then re-run dep.

link broken in README.md

In gotraining/topics/README.md the following link is broken:

Go Challenges
Learn Go by solving problems and getting feedback from Go experts!

Rename Pillar

@ardan-bkennedy when I discuss decoupling and go through the whole Xenia -> Pillar exercise I find myself stumbling on the name "Pillar" because it sounds so similar to the interface "Puller". I think this also creates some "who's on first" kind of confusion for the students as well. Let's rename it.

【about Nanosecond 】

Hi , according to ur blog , i write a test :
`
startingTime := time.Now().UTC()
time.Sleep( 1000 * time.Nanosecond )
endingTime := time.Now().UTC()

var duration time.Duration = endingTime.Sub( startingTime )

fmt.Printf( "%d \n", duration.Microseconds() )
`

the result is 1000

slices.Clip description

In the post - https://www.ardanlabs.com/blog/2023/08/golang-slices-clip-clone-compact.html

Figure 3 shows that after list = slices.Clip(list) new list slice has a different underlying array with size 1.

But according to this code this is wrong:

package main

import (
	"fmt"
)

func main() {
	var arr [10000]int
	fmt.Println("arr", &arr[0])
	fmt.Printf("Len(%d), Cap(%d)\n", len(arr), cap(arr))

	slArr := arr[:]
	fmt.Println("slArr", &slArr[0])
	fmt.Printf("Len(%d), Cap(%d)\n", len(slArr), cap(slArr))

	slArr = arr[:1:10]
	fmt.Println("slArr", &slArr[0])
	fmt.Printf("Len(%d), Cap(%d)\n", len(slArr), cap(slArr))

	sl := make([]int, 1, 10000)
	fmt.Println("sl", &sl[0])
	fmt.Printf("Len(%d), Cap(%d)\n", len(sl), cap(sl))

	sl = sl[:]
	fmt.Println("sl", &sl[0])
	fmt.Printf("Len(%d), Cap(%d)\n", len(sl), cap(sl))

	sl = sl[:1:10]
	fmt.Println("sl", &sl[0])
	fmt.Printf("Len(%d), Cap(%d)\n", len(sl), cap(sl))
}

Notice, address of &slArr[0] or &sl[0] doesn't change after changing the capacity.

Or did I understand smth wrong?

[question]: Purpose of the file "topics/go/concurrency/patterns/advanced/logger/logger.go"

Hi there!

I want to ask about some inconsistency. There are two loggers in "patterns" section ( topics/go/concurrency/patterns ):

The only difference between their main.go files is using custom/stdlib logger, but "advanced logger" has empty package logger (https://github.com/ardanlabs/gotraining/blob/master/topics/go/concurrency/patterns/advanced/logger/logger.go) - https://www.diffchecker.com/5vcK6nKY
It seems "advanced/logger" isn't used.

Is it a valid package?
Thank you!

Add Linux and BSD to the install list?

The front page assumes attenders are using either Windows or OSX, I have been finding an increasing number of Ubuntu, and Linux generally, users on workshops. Often these people can trivially install using packaging. Sadly though sometimes this leads to using an old version of Go. I suspect similar situation ofr the BSD users. It would be good to give these people sensible installation instructions on a par with Windows and OSX users.

[simulations] Use rand with non-fixed seed.

The simulations under gotraining/topics/go/algorithms/simulations/ use rand with a fixed seed. Using a fixed seed will produce the same output on every run.

A better way would be to use a non-fixed seed:

var r = rand.New(rand.NewSource(time.Now().UnixNano()))

day := r.Intn(daysInYear)

Sharing variable up the call stack

@ardan-bkennedy, thank you for this amazing course and repository organization.

During decoupling and in interface pollution topic, you have fixed the pollution, but the New function is sharing the concrete value of the type up the call stack.

composition/README.md#L63 - Playground Example

I know this is a very popular design, but I can't understand why do we need to allocate memory here and share the value instead of returning a copy of the value?

Do we prefer that the caller will have easier access to methods with pointer receiver if we share the value up the call stack over memory allocation and the risk of memory leak?

[QUESTION] Why pass a global var as argument

func processor(complete chan<- error) {

Hi @ardan-bkennedy,

why you pass the complete var into processor function when actually complete is a global variable that processor function can access it directly without passing it as an argument to it.

I'm currently joining your course Ultimate Go Programming on safaribooksonline, and I don't know where is the right place to ask you a question so I land it here.

Redirect from https://www.goinggo.net doesn't work

Hi there.

Just want to let you know, that redirect from https://www.goinggo.net doesn't work ( report http://r.h-t.co/en/3/6a52a920-cdd6-e811-8605-0003ff7328cc )
For example https://www.goinggo.net/2016/05/installing-go-and-your-workspace.html from Opening.md

But at the same time, http://www.goinggo.net works correctly ( as well as redirect to https://www.ardanlabs.com )

I've just sent a PR where found and replaced all www.goinggo.net -> www.ardanlabs.com/blog PR#277

Nevertheless, I suppose there might be links pointed to the previous domain.

Thank you!

UPD
http://www.goinggo.net/2016/05/installing-go-and-your-workspace.html redirects to https://www.ardanlabs.com/2016/05/installing-go-and-your-workspace.html ( without blog in the path )

Rework Maps Section

@ardan-bkennedy I want to take the existing map examples, break them apart, and reorder the content. I get the feeling that when this material was written it was assumed that the student was already familiar with maps and we are just covering them to nail down some of the "gotchas" as well as the best practices. Consider that the first example right off the bat is jumping into iterating over a map and how it is in an undefined order. If you are just learning maps this is a confusing place to start.

Here is how I want to teach the materials at least for Go Fundamentals. Do you think this would work with Ultimate? It's still basically the same content (though I expand the coverage of zero value for non-present keys)

Example 1: Declare, write, read, and delete

Start with the basics.

  • Create a map with make: users := make(map[string]user)
  • Set individual values in the map. users["Roy"] = user{"Rob", "Roy"}
  • Read individual values from the map. roy := users["Roy"]
  • Delete values from the map. delete(users["Roy"])

Example 2: Reading a non-present key

We just talked about delete so it seems natural to move on to this.

  • Reading a non-present key gives zero value. u := users["Roy"]
  • Use two-assignment form if you need to know. u, found := users["Roy"]
  • Talk about how we can conveniently write scores["anna"]++ without checking for existence.

Example 3: Map key type restrictions

This could be last after the range stuff? It just needs to be covered before we're done.

  • Explain how/why a map's key type must be "comparable". Can't be a slice, map, or func.

Example 4: Map literal and range

  • Declare a map with predefined values
  • Range over it twice. Show how order is pseudo-random.

Example 5: Ranging in a specific order

  • Show the existing example4.go which covers one way to iterate a map in a defined order.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.