Coder Social home page Coder Social logo

miekg / learninggo Goto Github PK

View Code? Open in Web Editor NEW
537.0 25.0 109.0 21.23 MB

Learning Go Book in mmark

Home Page: https://miek.nl/go

License: Other

Makefile 2.17% Go 58.62% JavaScript 1.72% HTML 7.63% CSS 27.85% Perl 2.03%
golang book free mmark exercises

learninggo's Introduction

Learning Go

This is the "Learning Go" book in mmark markdown. It is translated to HTML with mmark.

After some post processing (with some javascript) the end result, can be found here.

To Build

  • Download or go get mmark.
  • cd <repo-of-mmark>
  • go build
  • go install - optional

And then just make in this repository.

Notes

The stack exercise and solution uses struct which are not being dealt with yet.

learninggo's People

Contributors

aaylward avatar antoniomo avatar ariabov avatar benjamin-rood avatar bingohuang avatar bzhn avatar clivern avatar henkjan avatar jaturu avatar kartikynwa avatar krak-n avatar mamachanko avatar miekg avatar mziemys avatar piersc avatar rilutham avatar stevenmaude avatar theckman avatar walterxu 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

learninggo's Issues

Let jQuery create a TOC

Create TOC, with something ala

        function toc(){
          $("body").prepend("<div class=toc></div>");
          $("h1").each(function(){
            $("div.toc").append($(this).text()).append("<br/>");
          });
        }

the wrong way to organise a book

I’m making this comment too late, since the book seems to be done. This is the most common and worst way to organise a programming book. Nobody wants to read (yet another) chapter on arrays. Nobody’s end-goal is to create a type. Nobody who can already program wants to print hello world. Nobody wants to learn a language by reading the details of how assignment actually works.

It doesn’t matter how clear the writing of individual paragraphs is when it’s organised this way.

Toggle chapters

The answers for the exercises can now be toggled. Should we do the same for the chapters?

Missing word in basics.md

Hi, Should the sentence at line 28:
Next we another comment, but this one is enclosed...
be something like:
Next we have another comment, but this one is enclosed...

Fix PrintDefaults

From: #35 (comment)

There's also this problem:

The PrintDefaults at 4 5 will output the default help for the flags...

but couldn't figure out a way to resolve that: it's incorrectly displaying 4 and 5, not just 4.

Chapter 4, ex. "Minimum"

Not sure if a mistake, but the exercise is called "Minimum" and what we're looking for is the maximum of a list.

Create css style

Create a nice look and feel for the book.

Maybe a light and dark theme.

Interface "find maximum" question specification unclear

The problem is phrased as:

In the maximum exercise we created a max function that works on a slice of integers. The question now is to create a program that shows the maximum number and that works for both integers and floats. Try to make your program as generic as possible, although that is quite difficult in this case.

My implicit reading of that was the program should work on a slice of integers and a slice of floats, i.e. the reader should generalise their previous solution to floats too.

However, the solution currently in the text just compares two values.

For reference, code I wrote for it:

package main

import "fmt"

type sI []int

type sF []float64

type Greater interface {
    Greater(int, int) bool
    Len() int
    Value(int) interface{}
}

func (s sI) Greater(i int, j int) bool {
    return s[i] > s[j]
}

func (s sI) Len() int {
    return len(s)
}

func (s sI) Value(i int) interface{} {
    return s[i]
}

func (s sF) Greater(i int, j int) bool {
    return s[i] > s[j]
}

func (s sF) Len() int {
    return len(s)
}

func (s sF) Value(i int) interface{} {
    return s[i]
}

func findMax(g Greater) interface{} {
    max_index := 0
    for i := 1; i < g.Len(); i++ {
        if g.Greater(i, max_index) {
            max_index = i
        }
    }
    return g.Value(max_index)
}

func main() {
    s := sI{850, 5, 843, -6, 7, 16, 842}
    fmt.Println("Maximum of", s, "is", findMax(s))
    f := sF{5.5, 13.223, 2.1, -6.4, 843.958}
    fmt.Println("Maximum of", f, "is", findMax(f))
}

This solution has a similar structure to the proposed solution for the first max() question. It also has the advantage that it follows a similar pattern to that alluded to earlier in the chapter for bubble sorting.

Happy to submit a PR, but thought it worth asking what the fix should be: change the question text or the solution?

Bug in "How to Read this Book" section

This does not list the chapters properly:

Here's what you can expect from each chapter:

We'll look at the basic types, variables, and control structures available in the language.
Here we look at functions, the basic building blocks of Go programs.
We'll see that functions and data can be grouped together in packages. We'll also see how to document and test our packages.
We'll create our own types. We'll also look at memory allocations in Go.
We'll learn how to use interfaces. Interfaces are the central concept in Go, as Go does not support object orientation in the traditional sense.
We'll learn the go keyword, which can be used to start function in separate routines (called goroutines). Communication with those goroutines is done via channels.
Finally we'll see how to interface with the rest of the world from within a Go program. We'll see how to create files and read and write to and from them. We'll also briefly look into networking.

fix references

There are some old style tex references left, fix them all and make sure they are all correct.

Bugged and fixed solutions for cat exercise are identical

In the Chapter 5 exercises, the two solutions for the cat implementation are identical, aside from the inclusion of line labelling numbers.

However, the second is supposed to fix a bug in the first.

Diff of the two code snippets:

7c7
<   "io" 1

---
>   "io"
11c11
< var numberFlag = flag.Bool("n", false, "number each line")  2

---
> var numberFlag = flag.Bool("n", false, "number each line")
13c13
< func cat(r *bufio.Reader) { 3

---
> func cat(r *bufio.Reader) {
16,17c16,17
<       buf, e := r.ReadBytes('\n') 4
<       if e == io.EOF {            5

---
>       buf, e := r.ReadBytes('\n')
>       if e == io.EOF {
20c20
<       if *numberFlag { 6

---
>       if *numberFlag {
23c23
<       } else { 7

---
>       } else {

Is demo of reverse polish calculator too simple?

In Chapter "Packages",I'm afraid that demo of reverse polish calculator in exercises is too simple.The demo cann't resolve expression like this: 11+22*33*(2+5) .

Now I have completed a work to parse mathematical expression strings by double stack,just the classic “Reverse Polish Notation”.I hope you can accept this PR.

The comment in code is written by Chinese.Does it need to be English?

problems with make using mmark 2.0.29

learninggo.html does not "compile" using the current mmark 2.0.29.

~/learninggo $ make learninggo.html
mmark -html -head inc/head.html -css inc/learninggo.css learninggo.md > learninggo.html
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x113a138]

goroutine 1 [running]:
github.com/mmarkdown/mmark/mhtml.bibliographyItem(0x11ca8e0, 0xc00030b030, 0xc0000b1400, 0xc00030b001)
/Users/me/Library/golang/packages/src/github.com/mmarkdown/mmark/mhtml/hook.go:104 +0x298
github.com/mmarkdown/mmark/mhtml.RenderHook(0x11ca8e0, 0xc00030b030, 0x11cc880, 0xc0000b1400, 0x1, 0x0, 0xc0000d7701)
/Users/me/Library/golang/packages/src/github.com/mmarkdown/mmark/mhtml/hook.go:37 +0x38c
github.com/gomarkdown/markdown/html.(*Renderer).RenderNode(0xc0000eec60, 0x11ca8e0, 0xc00030b030, 0x11cc880, 0xc0000b1400, 0x1, 0x0)
/Users/me/Library/golang/packages/src/github.com/gomarkdown/markdown/html/renderer.go:914 +0x16e9
github.com/gomarkdown/markdown.Render.func1(0x11cc880, 0xc0000b1400, 0x10fd601, 0x0)
/Users/me/Library/golang/packages/src/github.com/gomarkdown/markdown/markdown.go:63 +0x61
github.com/gomarkdown/markdown/ast.NodeVisitorFunc.Visit(0xc0002f8fa0, 0x11cc880, 0xc0000b1400, 0x1, 0x0)
/Users/me/Library/golang/packages/src/github.com/gomarkdown/markdown/ast/node.go:545 +0x43
github.com/gomarkdown/markdown/ast.Walk(0x11cc880, 0xc0000b1400, 0x11cab60, 0xc0002f8fa0, 0x0)
/Users/me/Library/golang/packages/src/github.com/gomarkdown/markdown/ast/node.go:517 +0x70
github.com/gomarkdown/markdown/ast.Walk(0x11cc820, 0xc00025f650, 0x11cab60, 0xc0002f8fa0, 0x0)
/Users/me/Library/golang/packages/src/github.com/gomarkdown/markdown/ast/node.go:528 +0x1ba
github.com/gomarkdown/markdown/ast.Walk(0x11cbe00, 0xc00025e1c0, 0x11cab60, 0xc0002f8fa0, 0x0)
/Users/me/Library/golang/packages/src/github.com/gomarkdown/markdown/ast/node.go:528 +0x1ba
github.com/gomarkdown/markdown/ast.Walk(0x11cbda0, 0xc000088420, 0x11cab60, 0xc0002f8fa0, 0xc0002f8fa0)
/Users/me/Library/golang/packages/src/github.com/gomarkdown/markdown/ast/node.go:528 +0x1ba
github.com/gomarkdown/markdown/ast.WalkFunc(0x11cbda0, 0xc000088420, 0xc0002f8fa0)
/Users/me/Library/golang/packages/src/github.com/gomarkdown/markdown/ast/node.go:551 +0x4b
github.com/gomarkdown/markdown.Render(0x11cbda0, 0xc000088420, 0x11cb0c0, 0xc0000eec60, 0x11a4885, 0x13, 0x11a3402)
/Users/me/Library/golang/packages/src/github.com/gomarkdown/markdown/markdown.go:62 +0xd8
main.main()
/Users/me/Library/golang/packages/src/github.com/mmarkdown/mmark/mmark.go:172 +0x5c6
make: *** [Makefile:7: learninggo.html] Error 2

~/learninggo $ mmark -version
2.0.29

~/learninggo $ go version
go version go1.11 darwin/amd64

fix links to tables

Internal links to tables don't work.

This also needs some table number, which needs to be added to the caption: Table 1: bla bla
That 1 needs to be added to some div so we can reference it while resolving the references.

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.