{"id":18527681,"url":"https://github.com/helinwang/netchan","last_synced_at":"2025-05-14T21:32:59.957Z","repository":{"id":151250974,"uuid":"120141304","full_name":"helinwang/netchan","owner":"helinwang","description":"Send and receive over the network with the built-in Go channel.","archived":false,"fork":false,"pushed_at":"2018-02-05T19:57:36.000Z","size":21,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-17T06:28:52.640Z","etag":null,"topics":["channel","go","rpc"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/helinwang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-04T00:10:00.000Z","updated_at":"2021-12-31T10:48:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"c965888e-dca8-44f6-a62d-7ad612644c3e","html_url":"https://github.com/helinwang/netchan","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helinwang%2Fnetchan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helinwang%2Fnetchan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helinwang%2Fnetchan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helinwang%2Fnetchan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/helinwang","download_url":"https://codeload.github.com/helinwang/netchan/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254231084,"owners_count":22036294,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["channel","go","rpc"],"created_at":"2024-11-06T17:55:43.823Z","updated_at":"2025-05-14T21:32:59.863Z","avatar_url":"https://github.com/helinwang.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# netchan\n\n[![Build Status](https://travis-ci.org/helinwang/netchan.svg?branch=master)](https://travis-ci.org/helinwang/netchan)\n\nSend and receive over the network with the built-in Go channel.\n\n## Install\n\nWith a [correctly configured](https://golang.org/doc/install#testing) Go toolchain:\n\n```sh\ngo get -u github.com/helinwang/netchan\n```\n\n## Examples\n\nSend and receive over TCP and UNIX:\n\n```Go\nfunc Example() {\n\tconst (\n\t\tunixAddr = \"tmp\"\n\t\ttcpAddr  = \":8003\"\n\t\tname     = \"test\"\n\t)\n\n\t// Struct's field names should be exported, otherwise, they\n\t// will not be sent since they are ignored by the gob encoder.\n\ttype data struct {\n\t\tA int\n\t\tB float32\n\t}\n\n\ttcpSend := make(chan interface{})\n\tunixSend := make(chan interface{})\n\trecv := make(chan interface{})\n\n\t// this example shows sending and receiving over tcp and unix,\n\t// but you can use only tcp or unix, just send or just\n\t// receive.\n\tsr := netchan.NewSendRecv()\n\tgo func() {\n\t\terr := sr.ListenAndServe(\"tcp\", tcpAddr)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}()\n\n\tgo func() {\n\t\terr := sr.ListenAndServe(\"unix\", unixAddr)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}()\n\n\t// wait for the server to start\n\ttime.Sleep(30 * time.Millisecond)\n\n\ts := netchan.NewHandler(sr)\n\tgo func() {\n\t\terr := s.HandleSend(\"tcp\", tcpAddr, name, tcpSend)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}()\n\n\tgo func() {\n\t\terr := s.HandleSend(\"unix\", unixAddr, name, unixSend)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}()\n\n\tgo func() {\n\t\terr := s.HandleRecv(name, recv, reflect.TypeOf(data{}))\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}()\n\n\td := data{A: 1, B: 2}\n\ttcpSend \u003c- d\n\tr := (\u003c-recv).(data)\n\tfmt.Println(r)\n\n\td = data{A: 3, B: 4}\n\tunixSend \u003c- d\n\tr = (\u003c-recv).(data)\n\tfmt.Println(r)\n\t// Output:\n\t// {1 2}\n\t// {3 4}\n\n\terr := os.Remove(unixAddr)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelinwang%2Fnetchan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhelinwang%2Fnetchan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelinwang%2Fnetchan/lists"}