gofix for go's weekly version: weekly.2011-09-01

This commit is contained in:
mikespook 2011-09-05 12:41:53 +08:00
parent 22866616cd
commit e50c4533af
5 changed files with 500 additions and 502 deletions

View File

@ -205,7 +205,7 @@ func (client *Client) Status(handle string) (known, running bool, numerator, den
if job, err = client.readLastJob(STATUS_RES); err != nil { if job, err = client.readLastJob(STATUS_RES); err != nil {
return return
} }
data := bytes.Split(job.Data, []byte{'\x00'}, 5) data := bytes.SplitN(job.Data, []byte{'\x00'}, 5)
if len(data) != 5 { if len(data) != 5 {
err = os.NewError("Data Error.") err = os.NewError("Data Error.")
return return

View File

@ -66,7 +66,7 @@ func (job *ClientJob) Result() (data []byte, err os.Error) {
err = os.NewError("Work exception.") err = os.NewError("Work exception.")
fallthrough fallthrough
case WORK_COMPLETE: case WORK_COMPLETE:
s := bytes.Split(job.Data, []byte{'\x00'}, 2) s := bytes.SplitN(job.Data, []byte{'\x00'}, 2)
if len(s) != 2 { if len(s) != 2 {
err = os.NewError("Invalid data.") err = os.NewError("Invalid data.")
return return
@ -85,7 +85,7 @@ func (job *ClientJob) Update() (data []byte, err os.Error) {
err = os.NewError("The job is not a update.") err = os.NewError("The job is not a update.")
return return
} }
s := bytes.Split(job.Data, []byte{'\x00'}, 2) s := bytes.SplitN(job.Data, []byte{'\x00'}, 2)
if len(s) != 2 { if len(s) != 2 {
err = os.NewError("Invalid data.") err = os.NewError("Invalid data.")
return return

View File

@ -27,7 +27,6 @@ const (
// read buffer size // read buffer size
BUFFER_SIZE = 1024 BUFFER_SIZE = 1024
// \x00REQ // \x00REQ
REQ = 5391697 REQ = 5391697
REQ_STR = "\x00REQ" REQ_STR = "\x00REQ"
@ -87,7 +86,7 @@ type Job interface {
// Extract the error message // Extract the error message
func getError(data []byte) (eno os.Errno, err os.Error) { func getError(data []byte) (eno os.Errno, err os.Error) {
rel := bytes.Split(data, []byte{'\x00'}, 2) rel := bytes.SplitN(data, []byte{'\x00'}, 2)
if len(rel) != 2 { if len(rel) != 2 {
err = os.NewError("The input is not a error data.") err = os.NewError("The input is not a error data.")
return return

View File

@ -82,7 +82,6 @@ func (worker *Worker) AddServer(addr string) (err os.Error) {
return return
} }
// Add a function. // Add a function.
// Plz added job servers first, then functions. // Plz added job servers first, then functions.
// The API will tell every connected job server that 'I can do this' // The API will tell every connected job server that 'I can do this'
@ -224,7 +223,7 @@ func (worker *Worker) exec(job *WorkerJob) (err os.Error) {
} else { } else {
limit = 4 limit = 4
} }
jobdata := bytes.Split(job.Data, []byte{'\x00'}, limit) jobdata := bytes.SplitN(job.Data, []byte{'\x00'}, limit)
job.Handle = string(jobdata[0]) job.Handle = string(jobdata[0])
funcname := string(jobdata[1]) funcname := string(jobdata[1])
if job.DataType == JOB_ASSIGN { if job.DataType == JOB_ASSIGN {