Skip to content

Commit

Permalink
big update and rewrite of web apps chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
amattn committed Oct 29, 2018
1 parent 285ed3d commit cf5f5be
Show file tree
Hide file tree
Showing 251 changed files with 4,385 additions and 22 deletions.
36 changes: 36 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
Resources for http://GoTutorial.net

see the above website for details.


### Beginner Go

- Lesson 01: The Basic Basics
- Intro to Syntax, Numbers, Strings
- Lesson 02: Go with the Flow
- Expressions, Statements & Flow Control
- Lesson 03: Intro To Types
- Types, Arrays, Slices, Maps & Structs

### Advanced Go


- Lesson 04: Composition
- Embedded Fields & Interfaces
- Lesson 05: Concurrency
- Goroutines & Channels
- Lesson 06: Toolchain
- Compiling, Formatting, Testing, Profiling & More
- Lesson 07: Idiomatic Go
- Idiomatic Go
- Lesson 08: Web Apps in Go
- net/http, net/http/httptest, html/template, database/sql
- Lesson 09: JSON, JSON, JSON
- Encoder/Decoder, Anonymous Fields, Marshaler/Unmarshaler Interface, RawMessage
- Lesson 10: Testing
- Testing, Benchmarking, Coverage, httptest and more
- Lesson 12: I/O
- Readers, Writers & Buffers

### Other

- Lesson 11: Deployment
- Build/Release, Containers & A Case Study

Binary file added keynote/Go_Lesson_04.key
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed keynote/Go_Lesson_04.key/Data/[email protected]
Binary file not shown.
Binary file removed keynote/Go_Lesson_04.key/Data/[email protected]
Binary file not shown.
Binary file removed keynote/Go_Lesson_04.key/Data/[email protected]
Binary file not shown.
Binary file removed keynote/Go_Lesson_04.key/Data/[email protected]
Binary file not shown.
Binary file removed keynote/Go_Lesson_04.key/Data/[email protected]
Binary file not shown.
Binary file removed keynote/Go_Lesson_04.key/Data/[email protected]
Binary file not shown.
Binary file removed keynote/Go_Lesson_04.key/Data/[email protected]
Binary file not shown.
Binary file removed keynote/Go_Lesson_04.key/Data/[email protected]
Binary file not shown.
Binary file removed keynote/Go_Lesson_04.key/Data/[email protected]
Binary file not shown.
Binary file removed keynote/Go_Lesson_04.key/Data/[email protected]
Binary file not shown.
Binary file removed keynote/Go_Lesson_04.key/Data/[email protected]
Binary file not shown.
Binary file removed keynote/Go_Lesson_04.key/Data/[email protected]
Binary file not shown.
Binary file removed keynote/Go_Lesson_04.key/Data/[email protected]
Binary file not shown.
Binary file removed keynote/Go_Lesson_04.key/Data/[email protected]
Binary file not shown.
Binary file removed keynote/Go_Lesson_04.key/Data/st0-4106.jpg
Binary file not shown.
Binary file removed keynote/Go_Lesson_04.key/Data/st0-75.jpg
Binary file not shown.
Binary file removed keynote/Go_Lesson_04.key/Data/st1-4426.jpg
Binary file not shown.
Binary file removed keynote/Go_Lesson_04.key/Data/st10-2225.jpg
Binary file not shown.
Binary file removed keynote/Go_Lesson_04.key/Data/st11-4400.jpg
Binary file not shown.
Binary file removed keynote/Go_Lesson_04.key/Data/st12-4401.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st13-4402.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st14-4364.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st15-4394.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st17-4248.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st18-2817.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st19-2892.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st2-4420.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st20-2917.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st21-4249.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st22-2994.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st23-3108.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st24-3222.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st25-3241.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st26-4207.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st27-3819.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st28-4253.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st29-3805.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st3-4238.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st30-3882.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st31-4216.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st32-4204.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st4-4396.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st5-4398.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st6-4399.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st7-2188.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st8-1982.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Data/st9-4247.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/Index.zip
Binary file not shown.
9 changes: 0 additions & 9 deletions keynote/Go_Lesson_04.key/Metadata/BuildVersionHistory.plist

This file was deleted.

1 change: 0 additions & 1 deletion keynote/Go_Lesson_04.key/Metadata/DocumentIdentifier

This file was deleted.

Binary file removed keynote/Go_Lesson_04.key/Metadata/Properties.plist
Binary file not shown.
Binary file removed keynote/Go_Lesson_04.key/preview-micro.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/preview-web.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_04.key/preview.jpg
Diff not rendered.
Binary file modified keynote/Go_Lesson_05.key
Binary file not shown.
Binary file added keynote/Go_Lesson_07.key
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/[email protected]
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/[email protected]
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/[email protected]
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/[email protected]
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/[email protected]
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/[email protected]
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/[email protected]
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/[email protected]
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/[email protected]
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/[email protected]
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/[email protected]
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/[email protected]
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/[email protected]
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/[email protected]
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st0-4106.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st0-75.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st1-11162.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st10-11760.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st11-11902.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st11-12484.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st12-11689.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st12-11733.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st12-11888.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st12-14874.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st13-11753.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st14-11981.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st14-12627.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st14-13639.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st14-14415.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st14-15052.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st15-15056.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st17-12239.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st19-12350.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st2-12677.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st21-14538.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st21-14888.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st23-14487.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st24-14529.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st24-14765.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st28-13595.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st29-13523.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st29-13656.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st3-11781.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st30-13230.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st30-13526.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st30-13988.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st31-14081.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st31-14629.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st32-14090.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st33-14122.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st33-14679.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st37-13225.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st37-14780.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st39-14681.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st4-11510.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st4-13951.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st4-13970.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st4-14873.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st45-14783.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st46-14699.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st5-11530.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st5-14625.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st50-14962.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st51-15040.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st54-14255.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st6-11619.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st6-14610.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st75-11151.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Data/st8-12382.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/Index.zip
Binary file not shown.
11 changes: 0 additions & 11 deletions keynote/Go_Lesson_07.key/Metadata/BuildVersionHistory.plist

This file was deleted.

1 change: 0 additions & 1 deletion keynote/Go_Lesson_07.key/Metadata/DocumentIdentifier

This file was deleted.

Binary file removed keynote/Go_Lesson_07.key/Metadata/Properties.plist
Binary file not shown.
Binary file removed keynote/Go_Lesson_07.key/preview-micro.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/preview-web.jpg
Diff not rendered.
Binary file removed keynote/Go_Lesson_07.key/preview.jpg
Diff not rendered.
Binary file modified keynote/Go_Lesson_08.key
Binary file not shown.
2 changes: 2 additions & 0 deletions shortlink/slv0/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
slv*
gox_build.log
5 changes: 5 additions & 0 deletions shortlink/slv0/README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


## Usage

./build_all.sh
49 changes: 49 additions & 0 deletions shortlink/slv0/build_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/sh

# if one of our commands returns an error, stop execution of this script
set -o errexit

COMPONENT="shortlink"
GO_COMMAND="go"

# generate
echo "************************"
echo "$GO_COMMAND generate"
$GO_COMMAND generate

# build on the native or default platform
echo "************************"
echo "building native platform"
$GO_COMMAND build

echo "************************"
echo "vetting native platform"
$GO_COMMAND vet

# test on the native or default platform
echo "************************"
echo "testing native platform"
$GO_COMMAND test

# I like gox as a cross compilation tool: https://github.com/mitchellh/gox
# install with:
# go get github.com/mitchellh/gox

# build for our test or deployment platforms
# normally we do local development on darwin/amd64 and deploy to linux/amd64.
# feel free to add or remove if your situation differs
# also, in the normal case, most of the output of gox is redundant with
# the output from go build above, so in the normal case, we just
# redirect to a build log

# currently gox doesn't seem to support vgo...

GOX_BUILD_LOG="gox_build.log"
date >> $GOX_BUILD_LOG
echo "************************"
echo "crosscompiling: gox -osarch=\"darwin/amd64\" -osarch=\"linux/amd64\""
if ! gox -osarch="darwin/amd64" -osarch="linux/amd64" >> $GOX_BUILD_LOG 2>&1; then
echo "FAILURE: gox command failed to build for deployment architecture"
echo "check gox_build.log for more info"
fi

3 changes: 3 additions & 0 deletions shortlink/slv0/generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package main

//REMOVE_TO_ENABLE go:generate stringer -type=EXAMPLE
9 changes: 9 additions & 0 deletions shortlink/slv0/generate_tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

# if you are using modules you don't need this file

# if not, this is a great place to note what third party modules you may need to get.

go get -u golang.org/x/tools/cmd/stringer

go get -u github.com/lib/pq
42 changes: 42 additions & 0 deletions shortlink/slv0/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package main

import (
"flag"
"log"
"os"
"runtime"
"time"
)

var show_h bool
var show_help bool
var show_version bool

func init() {
flag.BoolVar(&show_h, "h", false, "show help message and exit(0)")
flag.BoolVar(&show_help, "help", false, "show help message and exit(0)")
flag.BoolVar(&show_version, "version", false, "show version info and exit(0)")
}

func main() {
log.Println(current_function(), "entering")
defer trace(current_function(), time.Now())

log.Printf("Starting %v (v%v, build %v, build date:%v)", os.Args[0], Version(), BuildNumber(), BuildDate())
log.Printf("os.Args: %v", os.Args)
log.Printf("Go (runtime:%v) (GOMAXPROCS:%d) (NumCPUs:%d)\n", runtime.Version(), runtime.GOMAXPROCS(-1), runtime.NumCPU())

// command line flags:
flag.Parse()

if show_version {
os.Exit(0)
}

if show_h || show_help {
flag.Usage()
os.Exit(0)
}

log.Println("Hello Gophers!")
}
3 changes: 3 additions & 0 deletions shortlink/slv0/templates.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package main

// TODO
24 changes: 24 additions & 0 deletions shortlink/slv0/util.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package main

import (
"log"
"runtime"
"time"
)

//
// Usage example: copy paste the two lines to the beginning of any function
// log.Println(current_function(), "entering")
// defer trace(current_function(), time.Now())
func trace(function_name string, start_time time.Time) {
elapsed := time.Since(start_time)
log.Printf("%s exiting ~ %s elapsed", function_name, elapsed)
}

func current_function() string {
pc := make([]uintptr, 15)
n := runtime.Callers(2, pc)
frames := runtime.CallersFrames(pc[:n])
frame, _ := frames.Next()
return frame.Function
}
31 changes: 31 additions & 0 deletions shortlink/slv0/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package main

import (
"fmt"
"log"
"time"
)

const (
internal_BUILD_TIMESTAMP = 1500000000
internal_BUILD_NUMBER = 0
internal_VERSION_STRING = "0.0.0"
)

func BuildDate() time.Time {
return time.Unix(internal_BUILD_TIMESTAMP, 0)
}
func BuildNumber() int64 {
return internal_BUILD_NUMBER
}
func Version() string {
return internal_VERSION_STRING
}

func VersionInfo() string {
return fmt.Sprintf("shortlink (%v, build %v, build date:%v)", Version(), BuildNumber(), BuildDate())
}

func LogVersionInfo() {
log.Printf(VersionInfo())
}
149 changes: 149 additions & 0 deletions shortlink/slv0/version_bump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
#!/bin/sh

# Last edit 2018-08-27

set -o nounset
set -o errexit

# you can add the following lines to .git/hooks/pre-commit to auto bump build num:
#
# ./version_bump.sh
# git add version.go

VERSION_GO_FILENAME="version.go"

usage(){
echo "Usage: $0 major|minor|patch|build"
echo " $0 build (just update buildnum, default)"
echo " $0 patch (1.0.PATCH)"
echo " $0 minor (1.MINOR.0)"
echo " $0 major (MAJOR.0.0)"
}

bump_build(){
CURRENT_BUILD_NUM=$(grep -o "internal_BUILD_NUMBER\\s*=\\s*[0-9]\\+" $VERSION_GO_FILENAME | grep -o "[0-9]\\+")
NEW_NUM=$((CURRENT_BUILD_NUM+1))
echo "Bumping build number, from ${CURRENT_BUILD_NUM} to $NEW_NUM"

sed -i.bak "s/internal_BUILD_NUMBER[[:space:]]*=[[:space:]]*[0-9]*/internal_BUILD_NUMBER\\ =\\ ${NEW_NUM}/g" $VERSION_GO_FILENAME


NEW_TS=$(date +%s)
echo "Bumping build timestamp new=$NEW_TS"

sed -i.bak "s/internal_BUILD_TIMESTAMP[[:space:]]*=[[:space:]]*[0-9][0-9]*/internal_BUILD_TIMESTAMP\\ =\\ ${NEW_TS}/g" $VERSION_GO_FILENAME

rm -f version.go.bak

# cleanup
go fmt version.go > /dev/null

FINAL_VERSION_STRING=$(grep -o "internal_VERSION_STRING\\s*=\\s\"[vV]*[0-9]*\.[0-9]*\.[0-9]*\"\\+" $VERSION_GO_FILENAME | grep -o "[0-9]*\.[0-9]*\.[0-9]*")
echo "v${FINAL_VERSION_STRING}"
}

bump_version_string(){
echo "Bumping ${POSITION} number, from ${XYZ_VERSION_STRING} to ${NEW_VERSION_STRING}"
sed -i.bak "s/internal_VERSION_STRING[[:space:]]*=[[:space:]]*\"[vV]*[0-9]*\.[0-9]*\.[0-9]*\"/internal_VERSION_STRING\\ =\\ \"${NEW_VERSION_STRING}\"/g" $VERSION_GO_FILENAME

bump_build
}


bump_patch(){
echo "patching"
NEW_PATCH_NUM=$((PATCH_NUM+1))
NEW_VERSION_STRING=${MAJOR_NUM}.${MINOR_NUM}.${NEW_PATCH_NUM}
bump_version_string
}

bump_minor(){
NEW_MINOR_NUM=$((MINOR_NUM+1))
NEW_PATCH_NUM="0"
NEW_VERSION_STRING=${MAJOR_NUM}.${NEW_MINOR_NUM}.${NEW_PATCH_NUM}
bump_version_string
}

bump_major(){
NEW_MAJOR_NUM=$((MAJOR_NUM+1))
NEW_MINOR_NUM="0"
NEW_PATCH_NUM="0"
NEW_VERSION_STRING=${NEW_MAJOR_NUM}.${NEW_MINOR_NUM}.${NEW_PATCH_NUM}
bump_version_string
}

tag(){
FINAL_VERSION_STRING=$(grep -o "internal_VERSION_STRING\\s*=\\s\"[vV]*[0-9]*\.[0-9]*\.[0-9]*\"\\+" $VERSION_GO_FILENAME | grep -o "[0-9]*\.[0-9]*\.[0-9]*")
git add version.go
git commit -m "tagging version v$FINAL_VERSION_STRING"
git tag v$FINAL_VERSION_STRING

echo "use the following command to push tag to origin:"
echo "git push && git push --tags"
}



if [ $# -eq 0 ]
then
bump_build
exit 0
elif [ $# -gt 1 ]
then
echo "too many arguments supplied"
usage
exit 1
fi


while [ "$1" != "" ]; do

PARAM=`echo $1 | awk -F= '{print $1}'`
VALUE=`echo $1 | awk -F= '{print $2}'`

# should be of form x.y.z
XYZ_VERSION_STRING=$(grep -o "internal_VERSION_STRING\\s*=\\s\"[vV]*[0-9]*\.[0-9]*\.[0-9]*\"\\+" $VERSION_GO_FILENAME | grep -o "[0-9]*\.[0-9]*\.[0-9]*")

MAJOR_NUM=$(echo "$XYZ_VERSION_STRING" | cut -d '.' -f 1)
MINOR_NUM=$(echo "$XYZ_VERSION_STRING" | cut -d '.' -f 2)
PATCH_NUM=$(echo "$XYZ_VERSION_STRING" | cut -d '.' -f 3)

POSITION=$1

case $PARAM in
-h | --help)
usage
exit 0
;;
build)
bump_build
exit 0
;;
patch)
bump_patch
exit 0
;;
minor)
bump_minor
exit 0
;;
major)
bump_major
exit 0
;;
tag)
tag
exit 0
;;
*)
echo "ERROR: unknown parameter \"$PARAM\""
usage
exit 1
;;
esac
shift
done




Loading

0 comments on commit cf5f5be

Please sign in to comment.