Use go Makefiles

This commit is contained in:
tj 2009-11-22 00:05:12 +01:00
parent f9ea765794
commit 841757090b
6 changed files with 51 additions and 36 deletions

View File

@ -1,31 +1,6 @@
GOFILES = irc.go irc_struct.go include $(GOROOT)/src/Make.$(GOARCH)
all: $(GOARCH) TARG=irc
GOFILES=irc.go irc_struct.go
clean: clean_$(GOARCH)
rm test
386:
8g $(GOFILES)
8g test.go
8l -o test test.8
amd64:
6g $(GOFILES)
6g test.go
6l -o test test.6
arm:
5g $(GOFILES)
5g test.go
5l -o test test.5
clean_amd64:
rm *.6
clean_386:
rm *.8
clean_arm:
rm *.5
include $(GOROOT)/src/Make.pkg

1
README
View File

@ -1 +0,0 @@
Event based irc client library. Dosen't do much yet.

15
README.markdown Normal file
View File

@ -0,0 +1,15 @@
Description
----------
Event based irc client library.
Install
----------
$ git clone git@github.com:thoj/Go-IRC-Client-Library.git
$ cd Go-IRC-Client-Library
$ make
$ make install
Example
----------
See example/test.go

26
example/Makefile Normal file
View File

@ -0,0 +1,26 @@
all: $(GOARCH)
clean: clean_$(GOARCH)
rm test
386:
8g test.go
8l -o test test.8
amd64:
6g test.go
6l -o test test.6
arm:
5g test.go
5l -o test test.5
clean_amd64:
rm *.6
clean_386:
rm *.8
clean_arm:
rm *.5

View File

@ -1,7 +1,7 @@
package main package main
import ( import (
"./irc"; "irc";
"fmt"; "fmt";
"os"; "os";
) )

10
irc.go
View File

@ -19,8 +19,8 @@ func reader(irc *IRCConnection) {
for { for {
msg, err := br.ReadString('\n'); msg, err := br.ReadString('\n');
if err != nil { if err != nil {
fmt.Printf("%s\n", err);
irc.perror <- err; irc.perror <- err;
return;
} }
irc.pread <- msg; irc.pread <- msg;
} }
@ -31,7 +31,8 @@ func writer(irc *IRCConnection) {
b := strings.Bytes(<-irc.pwrite); b := strings.Bytes(<-irc.pwrite);
_, err := irc.socket.Write(b); _, err := irc.socket.Write(b);
if err != nil { if err != nil {
irc.perror <- err fmt.Printf("%s\n", err);
irc.perror <- err;
} }
} }
} }
@ -149,8 +150,6 @@ func (irc *IRCConnection) handle_command(msg string) *IRCEvent {
e.Code = IRC_PING; e.Code = IRC_PING;
e.Message = matches[2]; e.Message = matches[2];
e.Error = os.ErrorString(matches[2]); e.Error = os.ErrorString(matches[2]);
;
irc.perror <- e.Error;
} }
return e; return e;
} }
@ -179,6 +178,7 @@ func handler(irc *IRCConnection) {
irc.EventChan <- e; irc.EventChan <- e;
case error := <-irc.perror: case error := <-irc.perror:
fmt.Printf("Piped error: %s\n", error);
ee := new(IRCEvent); ee := new(IRCEvent);
ee.Error = error; ee.Error = error;
ee.Code = ERROR; ee.Code = ERROR;
@ -209,7 +209,7 @@ func IRC(server string, nick string, user string, events chan *IRCEvent) (*IRCCo
irc.registered = false; irc.registered = false;
irc.pread = make(chan string, 100); irc.pread = make(chan string, 100);
irc.pwrite = make(chan string, 100); irc.pwrite = make(chan string, 100);
irc.perror = make(chan os.Error); irc.perror = make(chan os.Error, 10);
irc.EventChan = events; irc.EventChan = events;
irc.nick = nick; irc.nick = nick;
irc.user = user; irc.user = user;