mirror of
https://github.com/chai2010/advanced-go-programming-book.git
synced 2025-05-24 04:22:22 +00:00
add copyright
This commit is contained in:
parent
4a31483164
commit
f16ece9385
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
func main()
|
func main()
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
#include "funcdata.h"
|
#include "funcdata.h"
|
||||||
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
// #include <stdio.h>
|
// #include <stdio.h>
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
void SayHello() {
|
void SayHello() {
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
// +build ignore
|
// +build ignore
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
%module main
|
%module main
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
//#include <stdio.h>
|
//#include <stdio.h>
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
void SayHello(const char* s) {
|
void SayHello(const char* s) {
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
//void SayHello(const char* s);
|
//void SayHello(const char* s);
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
//void SayHello(char* s);
|
//void SayHello(char* s);
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
//#include <stdio.h>
|
//#include <stdio.h>
|
||||||
|
@ -1 +1,4 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
#include "./my_buffer.h"
|
#include "./my_buffer.h"
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "unsafe"
|
import "unsafe"
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
struct MyBuffer {
|
struct MyBuffer {
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
#include "./my_buffer.h"
|
#include "./my_buffer.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
typedef struct MyBuffer_T MyBuffer_T;
|
typedef struct MyBuffer_T MyBuffer_T;
|
||||||
|
|
||||||
MyBuffer_T* NewMyBuffer(int size);
|
MyBuffer_T* NewMyBuffer(int size);
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
#include "person.h"
|
#include "person.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
// #cgo CXXFLAGS: -std=c++11
|
// #cgo CXXFLAGS: -std=c++11
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
type Person struct {
|
type Person struct {
|
||||||
|
@ -1 +1,4 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
#include "person.h"
|
#include "person.h"
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "./person_capi.h"
|
#include "./person_capi.h"
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
//#include "./person_capi.h"
|
//#include "./person_capi.h"
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
typedef uintptr_t person_handle_t;
|
typedef uintptr_t person_handle_t;
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "C"
|
import "C"
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
# Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
# License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
default:
|
default:
|
||||||
go build -buildmode=c-shared -o gopkg.so main.go
|
go build -buildmode=c-shared -o gopkg.so main.go
|
||||||
python3 -c 'import gopkg; print(gopkg.system("time"))'
|
python3 -c 'import gopkg; print(gopkg.system("time"))'
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
# Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
# License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
default:
|
default:
|
||||||
go build -buildmode=c-shared -o say-hello.so main.go
|
go build -buildmode=c-shared -o say-hello.so main.go
|
||||||
gcc -Wall _test_so.c ./say-hello.so
|
gcc -Wall _test_so.c ./say-hello.so
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
#include "say-hello.h"
|
#include "say-hello.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
# Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
# License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
from ctypes import *
|
from ctypes import *
|
||||||
|
|
||||||
libso = CDLL("./say-hello.so")
|
libso = CDLL("./say-hello.so")
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "C"
|
import "C"
|
||||||
|
@ -1,2 +1,5 @@
|
|||||||
|
# Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
# License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
default:
|
default:
|
||||||
go tool cgo hello.go
|
go tool cgo hello.go
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
||||||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "C"
|
import "C"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user