Package main
package main
import ("fmt";"svr";"shutdown")
func main(){
fmt.Println("Inits ran OK");
}
src/svr/svr.go
package svr
import ("net";"os";"log";"fmt")
func init(){
Link,err:= net.Listen("unix","/tmp/XXXX");
if err!=nil{
log.Fatal("Terminating as unable to setup Database link");
os.Exit(1);}
go func(){
for{
_,err:=Link.Accept();
if err!=nil{
log.Fatal("Accept failed ",err);}
fmt.Println("Accept rcvd");
}
}();
}
src/shutdown/shutdown.go
package shutdown
import ("svr";"net";"os";"os/signal";"syscall")
func init(){
sigc:= make(chan os.Signal,1);
signal.Notify(sigc,os.Interrupt,syscall.SIGTERM)
go func(link net.Listener, c chan os.Signal){
sig:= <-c;
println("Shutting Down Now");
link.Close();
os.Exit(0);
}(svr.Link,sigc);
println("Shutdown handler initialised");
}
go run test.go gives me
bjc@sol2 ~/go4 $ go run test.go
shutdown
src/shutdown/shutdown.go:13:5: undefined: svr.Link
Would anyone be good enough to tell me what I am missing ?
Thanks in advancePreformatted text