move h2 out of source files
This commit is contained in:
parent
571a58ece4
commit
bc39dbc769
@ -1,84 +1,84 @@
|
||||
hello-world
|
||||
# values
|
||||
# variables
|
||||
# inline-assignment
|
||||
# constants
|
||||
# for
|
||||
# if-else
|
||||
# switch
|
||||
# arrays
|
||||
# slices
|
||||
# maps
|
||||
# range
|
||||
# functions
|
||||
# multiple-return-values
|
||||
# varadic-functions
|
||||
# closures
|
||||
# recursion
|
||||
# defer
|
||||
# panic
|
||||
# pointers
|
||||
# new
|
||||
# structs
|
||||
# methods
|
||||
# embedding
|
||||
# interfaces
|
||||
# errors
|
||||
# ok-guards
|
||||
# goroutines
|
||||
# concurrent-goroutines
|
||||
# channels
|
||||
# channel-buffering
|
||||
# channel-directions
|
||||
# synchronization
|
||||
# select
|
||||
# timeouts
|
||||
# scatter-gather
|
||||
# rate-limiting
|
||||
# worker-pools
|
||||
# non-blocking-channel-operations
|
||||
# closing-channels
|
||||
timers
|
||||
tickers
|
||||
# state-goroutine
|
||||
# state-mutex
|
||||
sorting
|
||||
sorting-by-functions
|
||||
# collection-functions
|
||||
# string-functions
|
||||
# string-formatting
|
||||
# regexs
|
||||
# bytes
|
||||
# json
|
||||
# time
|
||||
# epochs
|
||||
# elapsed-time
|
||||
# random-numbers
|
||||
# number-parsing
|
||||
# urls
|
||||
# sha1-hashes
|
||||
# base64-encoding
|
||||
# reading-files
|
||||
# writing-files
|
||||
line-filters
|
||||
# command-line-arguments
|
||||
# command-line-flags
|
||||
# environment-variables
|
||||
# spawning-processes
|
||||
# execing-processes
|
||||
# signals
|
||||
# exit
|
||||
# http-client
|
||||
# https-client
|
||||
# redis
|
||||
# postgres
|
||||
# hello-web
|
||||
# responses
|
||||
# request-routing
|
||||
# request-logging
|
||||
# static-content
|
||||
# basic-authentication
|
||||
# canonical-hosts
|
||||
# middleware
|
||||
# graceful-shutdown
|
||||
# https-servers
|
||||
Hello World
|
||||
# Values
|
||||
# Variables
|
||||
# Short Declarations
|
||||
# Constants
|
||||
# For
|
||||
# If/Else
|
||||
# Switch
|
||||
# Arrays
|
||||
# Slices
|
||||
# Maps
|
||||
# Range
|
||||
# Functions
|
||||
# Multiple Return Values
|
||||
# Varadic Functions
|
||||
# Closures
|
||||
# Recursion
|
||||
# Defer
|
||||
# Panic
|
||||
# Pointers
|
||||
# New
|
||||
# Structs
|
||||
# Methods
|
||||
# Embedding
|
||||
# Interfaces
|
||||
# Errors
|
||||
# OK Guards
|
||||
# Goroutines
|
||||
# Concurrent Goroutines
|
||||
# Channels
|
||||
# Channel Buffering
|
||||
# Channel Directions
|
||||
# Synchronization
|
||||
# Select
|
||||
# Timeouts
|
||||
# Scatter Gather
|
||||
# Rate Limiting
|
||||
# Worker Pools
|
||||
# Non-Blocking Channel Operations
|
||||
# Closing Channels
|
||||
Timers
|
||||
Tickers
|
||||
# State Goroutine
|
||||
# State Mutex
|
||||
Sorting
|
||||
Sorting by Functions
|
||||
# Collection Functions
|
||||
# String Functions
|
||||
# String Formatting
|
||||
# Regexs
|
||||
# Bytes
|
||||
# JSON
|
||||
# Time
|
||||
# Epochs
|
||||
# Elapsed Time
|
||||
# Random Numbers
|
||||
# Number Parsing
|
||||
# URLs
|
||||
# SHA1 Hashes
|
||||
# Base64 Encoding
|
||||
# Reading Files
|
||||
# Writing Files
|
||||
Line Filters
|
||||
# Command-Line Arguments
|
||||
# Command-Line Flags
|
||||
# Environment Variables
|
||||
# Spawning Processes
|
||||
# Execing Processes
|
||||
# Signals
|
||||
# Exit
|
||||
# HTTP Client
|
||||
# HTTPS Client
|
||||
# Redis
|
||||
# Postgres
|
||||
# Hello Web
|
||||
# Responses
|
||||
# Request Routing
|
||||
# Request Logging
|
||||
# Static Content
|
||||
# Basic Authentication
|
||||
# Canonical Hosts
|
||||
# Middleware
|
||||
# Graceful Shutdown
|
||||
# HTTPS Servers
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Arrays
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Base64 Encoding
|
||||
|
||||
package main
|
||||
|
||||
import b64 "encoding/base64"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Basic Authentication
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Bytes
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Canonical Hosts
|
||||
|
||||
package main
|
||||
|
||||
import "net/http"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Channel Buffering
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Channel Directions
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Channels
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Closing Channels
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Closures
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Collection Functions
|
||||
|
||||
package main
|
||||
|
||||
import "strings"
|
||||
@ -92,4 +90,4 @@ func main() {
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// todo: generics
|
||||
// todo: note no generics
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Command Line Arguments
|
||||
|
||||
// Use `os.Args` to access command-line arguments and
|
||||
// the name of the program.
|
||||
package main
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Command Line Flags
|
||||
|
||||
package main
|
||||
|
||||
import "flag"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Concurrent Goroutines
|
||||
|
||||
package main
|
||||
|
||||
import "time"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Constants
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Defer
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Elapsed Time
|
||||
|
||||
package main
|
||||
|
||||
import "time"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Embedding
|
||||
|
||||
package main
|
||||
|
||||
import "math"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Environment Variables
|
||||
|
||||
package main
|
||||
|
||||
// Use the `os` package to list, set, and get environment
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Epochs
|
||||
|
||||
// A common requirement in programms is getting the number
|
||||
// of seconds, milliseconds, or nanoseconds since the Unix
|
||||
// epoch. Here's how to do it in Go.
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Errors
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Exec'ing Processes
|
||||
|
||||
// In the previous chapter we looked at spawning external
|
||||
// process. We do this when we need the functionality
|
||||
// of another process accessable to a running Go process.
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Exit
|
||||
|
||||
// Use `os.Exit` to immediatly exit with a given
|
||||
// status.
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## For
|
||||
|
||||
// `for` is Go's only looping construct. Here are
|
||||
// two common forms.
|
||||
package main
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Functions
|
||||
|
||||
// Funcations are critical in Go as in any other language.
|
||||
// We'll look at some basic examples first.
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Goroutines
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Graceful Shutdown
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
@ -96,8 +94,5 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
// todo: clean up logging
|
||||
// todo: limit shutdown time
|
||||
// todo: pull in work from gobyexample-server
|
||||
// todo: factor out to cut-and-pastable against normal app
|
||||
// todo: credit http://blog.nella.org/?p=879
|
||||
// todo: comment about tcp servers
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Hello Web
|
||||
|
||||
package main
|
||||
|
||||
import "net/http"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Hello World
|
||||
|
||||
// Our first program will print the classic "Hello world"`
|
||||
// message. Here's the full source code.
|
||||
package main
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## HTTP Client
|
||||
|
||||
package main
|
||||
|
||||
import "net/http"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## HTTPS Client
|
||||
|
||||
package main
|
||||
|
||||
import "net/http"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## HTTPS Servers
|
||||
|
||||
package main
|
||||
|
||||
import "net/http"
|
||||
|
@ -1,6 +1,5 @@
|
||||
// ## If/Else
|
||||
// If/else in Go is straight-forward.
|
||||
|
||||
// If/else in go is straight-forward
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,2 +0,0 @@
|
||||
$ go run inline-assignment.go
|
||||
Hello assignment
|
@ -1,5 +1,3 @@
|
||||
// ## Interfaces
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## JSON
|
||||
|
||||
package main
|
||||
|
||||
import "encoding/json"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Line Filters
|
||||
|
||||
// A _line filter_ is a common type of program that reads
|
||||
// input on stdin, processes it, and then prints some
|
||||
// derived result to stdout. `grep` and `sed` are common
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Maps
|
||||
|
||||
// Maps are Go's built-in associative data type (sometimes
|
||||
// called "hashes" or "dicts" in other languages).
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Methods
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Middleware
|
||||
|
||||
package main
|
||||
|
||||
import "net/http"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Multiple Return Values
|
||||
|
||||
// Go has built-in support for multiple return values.
|
||||
// This feature is used often in idiomatic Go, for example
|
||||
// to return both result and error values from a function.
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## New
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Non-blocking Channel Operations
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Number Parsing
|
||||
|
||||
package main
|
||||
|
||||
// Package `strconv` provides the number parsing.
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## OK Guards
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Panic
|
||||
|
||||
// A `panic` means something went unexpectedly wrong.
|
||||
// Mostly we use it to fail fast on errors that
|
||||
// shouldn't occur during normal operation.
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Pointers
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Postgres
|
||||
|
||||
package main
|
||||
|
||||
import _ "github.com/bmizerany/pq"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Random Numbers
|
||||
|
||||
package main
|
||||
|
||||
// The `math/rand` package provides psuedo-random
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Range
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,4 +1,3 @@
|
||||
// ## Rate Limiting
|
||||
package main
|
||||
|
||||
import "time"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Reading files
|
||||
|
||||
package main
|
||||
|
||||
import "io/ioutil"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Recursion
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Redis
|
||||
|
||||
package main
|
||||
|
||||
import "github.com/fzzbt/radix/redis"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Regexs
|
||||
|
||||
package main
|
||||
|
||||
import "regexp"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Request Logging
|
||||
|
||||
package main
|
||||
|
||||
import "net/http"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## HTTP Server Routing
|
||||
|
||||
package main
|
||||
|
||||
import "github.com/bmizerany/pat"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Responses
|
||||
|
||||
package main
|
||||
|
||||
import "net/http"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Scatter-Gather
|
||||
|
||||
package main
|
||||
|
||||
import "sync"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Select
|
||||
|
||||
package main
|
||||
|
||||
import "time"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## SHA1 Hashes
|
||||
|
||||
package main
|
||||
|
||||
// Package `crypto/sha1` computes SHA1 hashes.
|
||||
|
@ -1,11 +1,9 @@
|
||||
// ## Inline Assignment
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
// `x := val` is shorthand for `var x type = val`.
|
||||
x := "Hello assignment"
|
||||
x := "Hello var"
|
||||
fmt.Println(x)
|
||||
}
|
2
src/short-declarations/short-declarations.sh
Normal file
2
src/short-declarations/short-declarations.sh
Normal file
@ -0,0 +1,2 @@
|
||||
$ go run short-declarations.go
|
||||
Hello var
|
@ -1,5 +1,3 @@
|
||||
// ## Signals
|
||||
|
||||
// Sometines we'd like our Go programs to intelligently
|
||||
// handle Unix signals. For example, we might want a
|
||||
// server to gracefully shutdown when it receives a
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Slices
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Sorting by Functions
|
||||
|
||||
// Sometimes we'll want to sort a collection by something
|
||||
// other than its natural order. For example, suppose we
|
||||
// wanted to sort strings by their length instead of
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Sorting
|
||||
|
||||
// Go's `sort` package implements sorting for builtins
|
||||
// and user-defined types. We'll look at sorting for
|
||||
// builtins first.
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Spawning Processes
|
||||
|
||||
// Sometimes our Go programs need to spawn other, non-Go
|
||||
// processes. For example, the syntax highlighting in this
|
||||
// book is implementing by spawning a [`pygmentize`]()
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## State Goroutine
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## State Mutex
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
@ -64,3 +62,5 @@ func main() {
|
||||
finalOpCount := atomic.LoadInt64(&opCount)
|
||||
fmt.Println(finalOpCount)
|
||||
}
|
||||
|
||||
// todo: "State with Mutexes?"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Static Content
|
||||
|
||||
package main
|
||||
|
||||
import "net/http"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## String Formatting
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## String Functions
|
||||
|
||||
// The standard library's `strings` package provides many
|
||||
// useful string-related functions.
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Structs
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Switch
|
||||
|
||||
// Switch statements allow...
|
||||
|
||||
package main
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Synchronization
|
||||
|
||||
// We can use channels to synchronize execution
|
||||
// accross goroutines. Here's an example of waiting
|
||||
// for another goroutine to finish.
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Tickers
|
||||
|
||||
// [Timers](timers) are for when you want to do
|
||||
// something once in the future - tickers are for when you
|
||||
// want to do something repeatedly at regular intervals.
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Time
|
||||
|
||||
package main
|
||||
|
||||
import "time"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Timeouts
|
||||
|
||||
package main
|
||||
|
||||
import "time"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Timers
|
||||
|
||||
// We often want to execute Go code at some point in the
|
||||
// future, or repeatedly at some interval. Go's built-in
|
||||
// timer and ticker features make both of these tasks
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## URLs
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Values
|
||||
|
||||
// Go has various value types, including strings,
|
||||
// different types of numbers, booleans, etc.
|
||||
package main
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Varadic Functions
|
||||
|
||||
// Varadic functions can be called with any number of
|
||||
// trailing arguments. This is useful if you don't know
|
||||
// number of arguments that will be needed for a function
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Variables
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,5 +1,3 @@
|
||||
// ## Worker Pools
|
||||
|
||||
package main
|
||||
|
||||
import "time"
|
||||
|
@ -1,11 +1,9 @@
|
||||
// ## Writing Files
|
||||
|
||||
package main
|
||||
|
||||
import "os"
|
||||
|
||||
func main() {
|
||||
file, err := os.Create("xx-file-write.txt")
|
||||
file, err := os.Create("writing-files.txt")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
</script>
|
||||
<body>
|
||||
<div class="chapter" id="{{.Id}}">
|
||||
<h2>{{.Name}}</h2>
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
{{range .Segs}}
|
||||
|
@ -130,7 +130,6 @@ type Chapter struct {
|
||||
func parseSegs(sourcePath string) []*Seg {
|
||||
lines := readLines(sourcePath)
|
||||
segs := []*Seg{}
|
||||
segs = append(segs, &Seg{Code: "", Docs: ""})
|
||||
lastSeen := ""
|
||||
for _, line := range lines {
|
||||
if line == "" {
|
||||
@ -142,9 +141,8 @@ func parseSegs(sourcePath string) []*Seg {
|
||||
}
|
||||
matchDocs := docsPat.MatchString(line)
|
||||
matchCode := !matchDocs
|
||||
lastSeg := segs[len(segs)-1]
|
||||
newDocs := (lastSeen == "") || ((lastSeen != "docs") && (lastSeg.Docs != ""))
|
||||
newCode := (lastSeen == "") || ((lastSeen != "code") && (lastSeg.Code != ""))
|
||||
newDocs := (lastSeen == "") || ((lastSeen != "docs") && (segs[len(segs)-1].Docs != ""))
|
||||
newCode := (lastSeen == "") || ((lastSeen != "code") && (segs[len(segs)-1].Code != ""))
|
||||
if newDocs || newCode {
|
||||
debug("NEWSEG")
|
||||
}
|
||||
@ -154,7 +152,7 @@ func parseSegs(sourcePath string) []*Seg {
|
||||
newSeg := Seg{Docs: trimmed, Code: ""}
|
||||
segs = append(segs, &newSeg)
|
||||
} else {
|
||||
lastSeg.Docs = lastSeg.Docs + "\n" + trimmed
|
||||
segs[len(segs)-1].Docs = segs[len(segs)-1].Docs + "\n" + trimmed
|
||||
}
|
||||
debug("DOCS: " + line)
|
||||
lastSeen = "docs"
|
||||
@ -163,7 +161,7 @@ func parseSegs(sourcePath string) []*Seg {
|
||||
newSeg := Seg{Docs: "", Code: line}
|
||||
segs = append(segs, &newSeg)
|
||||
} else {
|
||||
lastSeg.Code = lastSeg.Code + "\n" + line
|
||||
segs[len(segs)-1].Code = segs[len(segs)-1].Code + "\n" + line
|
||||
}
|
||||
debug("CODE: " + line)
|
||||
lastSeen = "code"
|
||||
@ -187,15 +185,16 @@ func parseAndRenderSegs(sourcePath string) []*Seg {
|
||||
}
|
||||
|
||||
func parseChapters() []*Chapter {
|
||||
chapterLines := readLines("meta/chapters.txt")
|
||||
chapterNames := readLines("meta/chapters.txt")
|
||||
chapters := make([]*Chapter, 0)
|
||||
for _, chapterId := range chapterLines {
|
||||
if (chapterId != "") && !strings.HasPrefix(chapterId, "#") {
|
||||
chapter := Chapter{Id: chapterId}
|
||||
chapterLines := readLines("src/" + chapterId + "/" + chapterId + ".go")
|
||||
chapter.Name = chapterLines[0][6:]
|
||||
chapterPath := "src/" + chapterId
|
||||
sourcePaths := mustGlob(chapterPath + "/*")
|
||||
for _, chapterName := range chapterNames {
|
||||
if (chapterName != "") && !strings.HasPrefix(chapterName, "#") {
|
||||
chapter := Chapter{Name: chapterName}
|
||||
chapterId := strings.ToLower(chapterName)
|
||||
chapterId = strings.Replace(chapterId, " ", "-", -1)
|
||||
chapterId = strings.Replace(chapterId, "/", "-", -1)
|
||||
chapter.Id = chapterId
|
||||
sourcePaths := mustGlob("src/" + chapterId + "/*")
|
||||
segs := []*Seg{}
|
||||
for _, sourcePath := range sourcePaths {
|
||||
sourceSegs := parseAndRenderSegs(sourcePath)
|
||||
|
Loading…
x
Reference in New Issue
Block a user