Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
30
Task/Distributed-programming/Go/distributed-programming-1.go
Normal file
30
Task/Distributed-programming/Go/distributed-programming-1.go
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/rpc"
|
||||
)
|
||||
|
||||
type TaxComputer float64
|
||||
|
||||
func (taxRate TaxComputer) Tax(x float64, r *float64) error {
|
||||
if x < 0 {
|
||||
return errors.New("Negative values not allowed")
|
||||
}
|
||||
*r = x * float64(taxRate)
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
c := TaxComputer(.05)
|
||||
rpc.Register(c)
|
||||
rpc.HandleHTTP()
|
||||
listener, err := net.Listen("tcp", ":1234")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
http.Serve(listener, nil)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue