New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

ghproxy-9d2.pages.dev/hslam/splice

Package Overview
Dependencies
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ghproxy-9d2.pages.dev/hslam/splice

Go Modules
Version
v1.0.3
Version published
Created
Source

splice

PkgGoDev Build Status codecov Go Report Card LICENSE

Package splice wraps the splice system call.

Get started

Install

go get github.com/hslam/splice

Import

import "github.com/hslam/splice"

Usage

Example

package main

import (
	"fmt"
	"github.com/hslam/splice"
	"io"
	"net"
	"time"
)

func main() {
	contents := "Hello world"
	lis, err := net.Listen("tcp", ":9999")
	if err != nil {
		panic(err)
	}
	defer lis.Close()
	done := make(chan bool)
	go func() {
		conn, _ := lis.Accept()
		defer conn.Close()
		time.Sleep(time.Millisecond * 100)
		if _, err := splice.Splice(conn, conn, 1024); err != nil && err != io.EOF {
			panic(err)
		}
		close(done)
	}()
	conn, _ := net.Dial("tcp", "127.0.0.1:9999")
	conn.Write([]byte(contents))
	buf := make([]byte, 64)
	n, _ := conn.Read(buf)
	fmt.Println(string(buf[:n]))
	conn.Close()
	<-done
}

Output

Hello world

License

This package is licensed under a MIT license (Copyright (c) 2020 Meng Huang)

Author

splice was written by Meng Huang.

FAQs

Package last updated on 05 Mar 2026

Related posts