Coder Social home page Coder Social logo

thewhitetulip / web-dev-golang-anti-textbook Goto Github PK

View Code? Open in Web Editor NEW
3.2K 96.0 280.0 1.99 MB

Learn how to write webapps without a framework in Go.

Home Page: https://leanpub.com/antitextbookGo/

Go 51.87% Python 0.60% HTML 21.04% CSS 26.48%
golang book golang-book go

web-dev-golang-anti-textbook's Introduction

About the book

Join the chat at https://gitter.im/thewhitetulip/web-dev-golang-anti-textbook

Source Read online Watch Download Code Pay?
Github Gitbooks YouTube series leanpub Tasks This book is free, but if you want to pay, you can buy it on leanpub.

What is this?

This is an easy to understand example based tutorial aimed at those who know a little of Go and nothing of webdev and want to learn how to write a webserver in Go. You will create a to do list application as you advance the chapters.

Please use the front end folder in the code folder to get the index.html of the Tasks project and work on it while reading this tutorial.

Supporting Docs

We have a YouTube series and a fully functioning web application as supporting documents. Tasks is the application which you'll as you read into the book

If you prefer learning by watching, YouTube series. The code corresponding to the YouTube series is available here. The code is published as branches, each video has a particular branch.

Multiversity

This guide is a part of the Multiversity initiative. The aim is to have high quality open source tutorials along with screencasts.

Contributing

We welcome all Pull Requests, please raise an issue before starting your work!

Backstory

I got feedback from a reddit user that maybe it is too early for me to start writing this book. Decades ago, a young student from the University of Helsinki had an endless debate with Andrew Tannenbaum on comp.minix. It was about monolithic kernels. Had the student listened to Andrew Tannenbaum, the world probably would not have had Linux. This is the whole point of open source projects, a little initiative from everyone goes a long way. I would like to thank everyone who gave their suggestions on reddit and HN.

Philosophy

  • Through this book we want to teach how to develop web applications in Go. We expect the reader to know the basics of Go but we assume the reader knows nothing about how to write web applications.
  • The book shall comprise of chapters, if the topic is huge and doesn't fit into one chapter, then we split into multiple chapters, if possible.
  • Each chapter should be split into logical parts or sections with a meaningful title which'll teach the reader something.
  • Every concept should be accompanied by the Go code (if there is any), for sneak peek type sections write the Go pseudo code, writing just the necessary parts of the code and keeping everything else.
  • The code shouldn't be more than 80 characters wide because in the PDF versions of the book the code is invisible.
  • Brevity is the soul of wit, please keep the description as small as possible. This doesn't mean we skip it, but try to explain it in as simple words as possible. In such cases do explain the concept.
  • In the todo list manager which we are creating, we'll strive to implement as much functionality as possible to give a taste of practical Go programming to the reader. In cases where we re-implement stdlib stuff, we should mention it clearly.
  • The main title should have one #, sections should have 2 #'s sub section should have 4 and notes should have 6 #'s (note should have a title too).
  • Multi-line code should use syntax fencing, single line of code can be indented using tabs or by backticks.

Written with love in India with help from the Internet.

License

Book License: CC BY-SA 3.0 License

Note

  1. The Go Programming Basics section has been adapted from build-web-application-with-golang by astaxie Links were updated to refer the correct aspects of the current book, titles were updated to fit into this book. Modifications to the content was done to suit to the style of the book.
  2. The gopher in the cover page is taken from https://golang.org/doc/gopher/appenginegophercolor.jpg without modifications.
  3. The chapter on database is adapted from https://github.com/VividCortex/go-database-sql-tutorial/ with modifications.

Links

web-dev-golang-anti-textbook's People

Contributors

a2-nier avatar alexbenic avatar appleboy avatar atc0005 avatar benkasminbullock avatar chinjon avatar codelingobot avatar davebarda avatar dgrosenblatt avatar electrofocus avatar giancarlos avatar gitter-badger avatar hartzell avatar jancarloviray avatar jsteenb2 avatar lrstanley avatar lukelindsey avatar mikaelm1 avatar qbantek avatar roebuk avatar screamingtaco avatar smihir avatar sprstnd avatar techmexdev avatar tedyoung avatar thewhitetulip avatar tml avatar trosel avatar wadtech avatar yayudev 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

web-dev-golang-anti-textbook's Issues

isHTTPOnly should be HTTPOnly

In 4.0authentication.md

Cookies are stored in our browsers, for security reasons we need to enable the "isHTTPOnly" field of our cookies, so only our webapplication can read the cookie.

the field name should be HTTPOnly base on the code below.

error undefined: message in chapter 2.1

Using go 1.7 on osx and working through 2.1WebAppDesign.md I get errors when running go build and build failure.

± go build
# github.com/adrinux/Tasks
./main.go:41: undefined: message
./main.go:50: undefined: message
./main.go:59: undefined: message
./main.go:68: undefined: message
./main.go:77: undefined: message
./main.go:86: undefined: message
./main.go:95: undefined: message
./main.go:104: undefined: message
./main.go:113: undefined: message
./main.go:122: undefined: message
./main.go:122: too many errors

It seems message is out of scope when calling write. Declaring it first and only assigning within if works ok:

func ShowAllTasksFunc(w http.ResponseWriter, r *http.Request) {
    var message string
    if r.Method == "GET" {
        message = "all pending tasks GET"
    } else {
        message = "all pending tasks POST"
    }
    w.Write([]byte(message))
}

Type in intro to Go.

In the godoc section, there is the following sentence:

“The packages were comments aren’t present show up as blank pages in godoc.”

This should be:

“The packages where comments aren’t present show up as blank pages in godoc.”

Typo?

At 02.6 Interface

func main() {
    mike := Student{Human{"Mike", 25, "222-222-XXX"}, "MIT", 0.00}
    paul := Student{Human{"Paul", 26, "111-222-XXX"}, "Harvard", 100}
    sam := Employee{Human{"Sam", 36, "444-222-XXX"}, "Golang Inc.", 1000}
    tom := Employee{Human{"Sam", 36, "444-222-XXX"}, "Things Ltd.", 5000}

Shouldn't Tom have different values as Sam?

func main() {
    mike := Student{Human{"Mike", 25, "222-222-XXX"}, "MIT", 0.00}
    paul := Student{Human{"Paul", 26, "111-222-XXX"}, "Harvard", 100}
    sam := Employee{Human{"Sam", 36, "444-222-XXX"}, "Golang Inc.", 1000}
    tom := Employee{Human{"Tom", 48, "333-222-XXX"}, "Things Ltd.", 5000}

Overall Editorial Theme

Hi @brudgers I missed out on your comment on my HN post, and now there is no way to contact you. The editorial theme I have mentioned in the readme document here, is there more information required on that?

What prompted writing this book:

While learning web dev with Go it was very difficult to understand real life examples, most of all the tutorials/books I read gave some ridiculously simple examples and then somehow expect the total newbie to understand all the complicated logic that goes with an actual real life webapp.

Also PRs are welcome!

A package with example code

I couldn't find where the examples code is, as I am interested to contribute the code and tests too. So maybe you should add a subdirectory named examples so all the examples code can be there.

or if you have it somewhere else please let know.

PS: I was about to write a book in my local language( swahili, I'm from tanzania), now I don't think it is necessary. Will instead contribute to this one so maybe in the future I will just need to translate this.

Why not use ParseGlob in the templates example?

Seems like this code in the templates example is just reproducing the ParseGlob method:

Reading template:

        templates, err = template.ParseFiles(allFiles...)
        
Where allFiles is populated as below:

        var allFiles []string
        templatesDir := "./public/templates/"
        files, err := ioutil.ReadDir(templatesDir)
        if err != nil {
            fmt.Println("Error reading template dir")
        }
        for _, file := range files {
            filename := file.Name()
            if strings.HasSuffix(filename, ".html") {
                allFiles = append(allFiles, templatesDir+filename)
            }
        }
        

For example, in my program this is the exact code:

var tmplDir = "/home/ben/projects/bagapp2/tmpl/"

var templates = template.Must(template.ParseGlob(tmplDir + "*.html"))

How do you prefer pull requests to be constructed?

@thewhitetulip

As an example, if there are header level changes, typos and spacing adjustments, do you want them combined into fewer PRs or more focused on a specific type of change?

If combined, would you find it helpful to have multiple commits per PR (e.g., one file per commit with all changes to that file) or squashed to one commit containing all changes?

I've got some notes from going through the text (only the first pass at reading as I have much to learn from your book) and would like to begin compiling the changes into acceptable PRs. I figure I would touch base and confirm some details before investing too much work into the effort just yet.

Thanks.

Some header levels are inconsistent, spacing off

Some headers jump sequence, others have inconsistent spacing around them which (I vaguely recall) interferes with some rendering.

Going to reference this issue for an upcoming PR, potential further discussion.

How do you generate new ebooks from content in this repo?

First of all, many thanks for providing both the book and the source files used to produce the book. I'm a newbie to Go and have found the book very helpful as a companion to some other books I'm working through, though it is without a doubt very useful all on its own.

As I work through the material, I've found some minor issues, several of which have been reported and fixed by Pull Requests submitted by others (e.g., #92). I've got some others that I wish to submit, but I'd like to test the changes by generating fresh ebooks for comparison, either before submitting PRs or just after to proof the work.

I suspect that perhaps you're using pandoc, but wanted to touch base and confirm before I went in that direction.

Thanks in advance for your help.

Typo?

In chapter: 2.0implementationBasics.md,

We take a sub string of the URL and remove the /delete/ part and we have the ID of the task.

but the code above we strip the /tasks/ actually, is this a typo?

Translate to Chinese

Good evening
This project looks great. I am a gopher from China. Maybe I want to translate the Chinese version. Can I have a try?

Key Value store in database section

The database part is using sqlite which is a pain to install and adds more complexity to the end user. I suggest there should be another section which uses nosql which is pure go( I suggest bolt).

I willl be happpy to write that section about bolt, as I have been using it for fun and even have this library to help with bolt.

The benefits of adding options to use bolt will be

  • Fast setup. The readers will be fast up and running following the examples.
  • The examples are less complext meaning it can also be a way for readers to have a handy perspective of how real web apps might look like.

runtime.Gosched usage is likely to lead readers astray

While this might well be the shortest way you found to demonstrate the output you wanted, training users toward this function stands a good chance of them trying to use it to solve early problems it is not suitable for.

How do you feel about moving code comments from to-the-right to on-top?

@thewhitetulip

I found several cases while reading the epub version that code comments to the right of the code they were referencing were forcefully wrapped around to the next line, potentially disrupting the flow of the code. How do you feel about moving those to just above the code in question?

I'm attaching a screenshot illustrating how it displays in Google Play Books, though the content looks similar on mobile devices.

web_apps_in_go_comments_to_the_right_example_2019-07-15

Proposed adjustment (or some similar variation):

 // use `…` to replace the length parameter and Go will
// calculate it for you.
c := [...]int{4, 5, 6}

I'm willing to offer a PR with fixes for the ones I highlighted while reading through the book if you're interested.

Error with command go install github.com/mohamedmehdigara/hello@latest

Error msg: go install github.com/mohamedmehdigara/hello@latest: no matching versions for query "latest"

because this command: go install github.com/mohamedmehdigara/hello

gave the following error msg: go install: version is required when current directory is not in a module
Try 'go install github.com/mohamedmehdigara/hello@latest' to install the latest version

Multiple headers not rendering properly

I noticed that while reading the epub version the level 2 header for Constants was rendered as ## Constants, literally within the text instead of a formatted header as intended. I double-checked and the 2018-06-09 version available from leanup has the same issue in the PDF format also.

Attaching a screenshot for illustration.
constants_header_not_rendering_properly_2019-06-16

I briefly looked over the source Markdown file, but I can't tell for sure if the issue has been addressed since the 2018-06-09 version was released.

Tagalog Translation

Hi, I'm interested in contributing for this project - translating it into Tagalog. Is it okay for me to do so? Thanks :)

Items pending for Release1

  • Convert the formatting from gitbook to leanpub
  • Make this as a Go repository
  • make images smaller
  • change file names
  • upgrade Go from 1.5 to 1.7, all examples
  • chapter on git
  • chapter on db should be coherent, it is all a mess right now.
  • chapter on unit testing
  • updated API chapter
  • a command line REST client
  • Valid code examples from start to end
  • AJAX! and JS
  • rewrite the task app?
  • extensive modifications to the chapters
  • new features of Go like HTTP2
  • advance topics like content negotiation & compression
  • socket programming (Found an excellent book, asked the author for permission, he gave it. IT is CC licensed, the same as this book https://jan.newmarch.name/go/)
  • websockets
  • working with XML and file IO in general
  • NoSQL chapter

Not hashing passwords

You are teaching people some bad practices by not hashing passwords. You should never store plain text passwords.

Typo error found

In the map section of the document

m := make(map[string]string)
m["Hello"] = "Bonjour"
m1 := m
m1["Hello"] = "Salut"  // now the value of m["hello"] is Salut

In the comment, it got to be m["Hello"]

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.