Giter Club home page Giter Club logo

goto's People

Contributors

adg avatar kbrock avatar kedebug avatar nf 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

goto's Issues

goto patch for golang rev fd6ade18359d

I can not compile the sample. Here is my patch.

I apply gofix on goto/*.go and try to fix bench.go manual.

--- a/bench/bench.go
+++ b/bench/bench.go
@@ -83,7 +83,7 @@ func get() {
if r.StatusCode != 302 {
log.Println("get: wrong StatusCode:", r.StatusCode)
}

  •   if l := r.Header["Location"]; l != fooUrl {
    
  •   if l := r.Header["Location"][0]; l != fooUrl {
            log.Println("get: wrong Location:", l)
    }
    

Channels instead of Mutex

Is it not possible to avoid the use of sync.RWMutex in this example and use channels instead? Would that not be more idiomatic?

I understand why you are using Mutex but was it not possible to use channels instead?

gob data becomes unhappy after multiple runs of goto

store.gob is a file opened with O_APPEND for writes and gobs are appended to it. But it looks like this confuses the gob decoder after the first execution of the program. When it runs, it creates a gob Encoder object, and each new gob encoder will always include the type information into the file content. The result is redundant type definitions in the file. So the file will look like this:

.gob type defs
.data
.data
<stop program, start again>
.gob type defs
.data
.data

As a result, the decoder shows a warning (extra data in buffer) and interrupts the decoding.

One possible solution is to write to a different file in each execution, but read from all of them during load(). Or alternatively load() could decode the file in logical blocks, each using a separate Decoder object.

(I don't know if you had plans to update this tool, but even if you don't I thought it was worth documenting this issue anyway.)

Clarify license

Hi Andrew. Can people copy this source code? Could you please clarify the license? It's actually pretty useful :-).

Thanks!

  • Yves

File not written in the first run of the program

Running the following code does not write to the file in the first run but keeps adding to the file in all subsequent runs with 'extra data in buffer' error. The file size is zero after first run and keeps growing after that. This is because the file data is not being read into the map.

package main

import (
"fmt"
"gob"
"log"
"os"
"strconv"
)

var tm = make(tmap)

type tmap map[string]string
type rec struct {
name, id string
}

func writerec(name, id string) os.Error {
f, err := os.OpenFile("data.dat", os.O_CREATE|os.O_RDWR|os.O_APPEND, 0666)
defer f.Close()
if err != nil {
log.Println("writefile method file creation error : ", err)
}
fmt.Println("Opened the file writing the record.")
e := gob.NewEncoder(f)
return e.Encode(rec{name, id})
}
func loadfile() {
f, err := os.OpenFile("data.dat", os.O_CREATE|os.O_RDWR|os.O_APPEND, 0666)
if err != nil {
log.Println("writefile method file creation error : ", err)
}
d := gob.NewDecoder(f)
var r rec
for {
if err := d.Decode(&r); err == nil {
tm[r.name] = r.id
}
}
defer f.Close()
return
}
func gendata(c int) {
val := "abcdefghijklmno"
key := "abcdefghijklmnopqrstuvwxyzabcdefghijklmno"
for i := 0; i < c; i++ {
add := strconv.Itoa(i)
a := key + add
if _, ok := tm[a]; ok {
fmt.Println(key + add + " " + "is present")
} else {
fmt.Println(key + add + " " + "is not present")
tm[a] = val
writerec(a, val)
}
}
}
func main() {
gendata(5)
gendata(10)
gendata(15)

}

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.