Giter Site home page Giter Site logo

packtworkshops / the-go-workshop Goto Github PK

View Code? Open in Web Editor NEW
132.0 12.0 88.0 6.78 MB

A New, Interactive Approach to Learning Go

License: MIT License

Go 98.93% HTML 1.03% CSS 0.04%
go golang fmt go-library go-package go-import go-modules go-routine go-channel go-panic

the-go-workshop's People

Contributors

gobins avatar jleasor avatar packtsnehalt avatar packtsupport avatar pournamij avatar samhennessy avatar

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

the-go-workshop's Issues

found errors in chapter 16, activity 16.02

it is not reading the last numbers from the files leading to wrong sum of even and odd numbers due to returned on reaching EOF.
second error: it was reading '\r', so had to trim it too. I did a quick ugly solution:
func source(filename string, out chan int, wg *sync.WaitGroup) {
f, err := os.Open(filename)
if err != nil { panic(err) }

rd := bufio.NewReader(f)
for {
	str, err := rd.ReadString('\n')
	if err != nil {
		if err.Error() == "EOF" {
			i, err := strconv.Atoi(str) // ugly code- repetition but the job is done
			fmt.Println(i)
			if err != nil { panic(err) }
			out <- i
			f.Close()
			wg.Done()
			return
		} else { panic(err) }
	}
	str     = strings.TrimRight(str, "\r\n")
	i, err := strconv.Atoi(str)
	fmt.Println(i)
	if err != nil { panic(err) }
	out <- i
}

}

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.