defer log + webassembly

This commit is contained in:
Mihalis Tsoukalos 2019-01-19 21:17:03 +02:00
commit a076a3a481
2 changed files with 13 additions and 7 deletions

View file

@ -9,8 +9,8 @@ import (
var LOGFILE = "/tmp/mGo.log"
func one(aLog *log.Logger) {
aLog.Println("--------")
defer aLog.Println("--------")
aLog.Println("-- FUNCTION one ------")
defer aLog.Println("-- FUNCTION one ------")
for i := 0; i < 10; i++ {
aLog.Println(i)
@ -18,8 +18,8 @@ func one(aLog *log.Logger) {
}
func two(aLog *log.Logger) {
aLog.Println("--------")
defer aLog.Println("--------")
aLog.Println("---- FUNCTION two")
defer aLog.Println("FUNCTION two ------")
for i := 10; i > 0; i-- {
aLog.Println(i)
@ -28,15 +28,12 @@ func two(aLog *log.Logger) {
func main() {
f, err := os.OpenFile(LOGFILE, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
fmt.Println(err)
return
}
defer f.Close()
// LstdFlags = Ldate | Ltime
// Initial values for the standard logger
iLog := log.New(f, "logDefer ", log.LstdFlags)
iLog.Println("Hello there!")
iLog.Println("Another log entry!")

View file

@ -0,0 +1,9 @@
package main
import (
"fmt"
)
func main() {
fmt.Println("Creating WebAssembly code from Go!")
}