Skip to content

Commit 0f21338

Browse files
committed
update readme, little lib
1 parent 703d101 commit 0f21338

File tree

5 files changed

+75
-6
lines changed

5 files changed

+75
-6
lines changed

.github/workflows/t1.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
#server: ${{ secrets.IRCSRV }}
6666
#port: ${{ secrets.IRCPORT }}
6767
tls: true
68-
channel: "#vknuts"
68+
channel: "#cygo"
6969
nickname: gareport
7070
message: status ${{ matrix.platform }} ${{ job.status }} https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks?check_suite_id= https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks/0/logs
7171

readme.md

+34-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,40 @@
1-
Go compiler to C, with a generic library contains Go core features, like goroutine,channel,GC.
1+
Compile Go to C, with a generic library contains Go core features, like goroutine,channel,GC.
22

33
That's will generate minimal binary. The farther plan is compile any Go package to C.
44

5+
### The pain of Go
6+
* Too large binary size
7+
* Not friendly with C
8+
* Builtin string/array/map no methods
9+
* Too verbosity error handling, not like the Go2 `try` error handling proposal
10+
511
### Features
612
* goroutine
713
* channel
14+
* defer
815
* GC
916
* CGO
1017
* interface
18+
* closure
19+
* string/array/map with lot builtin methods
20+
* `catch` statement error handling
21+
22+
### Install
23+
24+
```
25+
cd $GOPATH
26+
git clone https://github.com/kitech/cygo
27+
cd cygo/bysrc
28+
go build -o cygo
29+
```
30+
31+
### Example
32+
33+
```
34+
./cygo ./tpkgs/hello
35+
cmake .
36+
make
37+
```
1138

1239
### Supported important syntax
1340
* defer
@@ -17,12 +44,16 @@ That's will generate minimal binary. The farther plan is compile any Go package
1744
### Todos
1845
* [ ] dynamic stack resize
1946
* [ ] correct and more safe point for GC
47+
* [ ] support more OS/platforms
48+
* [ ] so much to do
2049

2150
### Supported original Go packages
2251
* unsafe
2352
* errors
2453

2554
### 资料
26-
* [ ] Let's Build A Simple Interpreter https://github.com/rspivak/lsbasi
27-
* [ ] dwarf https://github.com/gimli-rs/gimli
55+
* minigo
56+
* tinygo
57+
* Let's Build A Simple Interpreter https://github.com/rspivak/lsbasi
58+
* dwarf https://github.com/gimli-rs/gimli
2859

scripts/build-bysrc-linux.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ cp -a $GOPATH/src/github.com/kitech/goplusplus $GOPATH/src/gopp
2020
cp -a $PWD $GOPATH/src/
2121
ln -sv $PWD/xgo $GOPATH/src/
2222

23-
cd $GOPATH/src/cxrt/bysrc
23+
cd $GOPATH/src/cygo/bysrc
2424
pwd
2525

2626
go env

scripts/build-bysrc-macos.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ cp -a $GOPATH/src/github.com/kitech/goplusplus $GOPATH/src/gopp
2020
cp -a $PWD $GOPATH/src/
2121
ln -sv $PWD/xgo $GOPATH/src/
2222

23-
cd $GOPATH/src/cxrt/bysrc
23+
cd $GOPATH/src/cygo/bysrc
2424
pwd
2525

2626
go env

xgo/xos/os.go

+38
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package xos
99
#include <fcntl.h>
1010
#include <unistd.h>
1111
#include <sys/syscall.h>
12+
#include <sys/utsname.h>
1213
1314
#include <sys/types.h>
1415
#include <dirent.h>
@@ -280,6 +281,43 @@ func Wkdir() string {
280281
}
281282
return s
282283
}
284+
func Tmpdir() string {
285+
var s string
286+
s = Getenv("TMPDIR")
287+
s = ifelse(s.len == 0, "/tmp", s)
288+
return s
289+
}
290+
291+
type Utsname struct {
292+
sysname string
293+
nodename string
294+
release string
295+
version string
296+
machine string
297+
domainname string
298+
}
299+
300+
func (uto *Utsname) String() string {
301+
return uto.sysname + " " + uto.nodename + " " +
302+
uto.release + " " + uto.version + " " + uto.machine
303+
}
304+
305+
func Uname() string {
306+
uts := &C.struct_utsname{}
307+
rv := C.uname(&uts)
308+
if rv != 0 {
309+
println(Errmsg())
310+
return ""
311+
}
312+
uto := &Utsname{}
313+
uto.sysname = gostring(uts.sysname)
314+
uto.nodename = gostring(uts.nodename)
315+
uto.release = gostring(uts.release)
316+
uto.version = gostring(uts.version)
317+
uto.machine = gostring(uts.machine)
318+
// uto.domainname = gostring(uts.domainname)
319+
return uto.String()
320+
}
283321

284322
func Umask(mask int) int {
285323
rv := C.umask(0)

0 commit comments

Comments
 (0)