Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for net/http Packages at Compile time #4822

Open
davidmdm opened this issue Mar 20, 2025 · 3 comments
Open

Support for net/http Packages at Compile time #4822

davidmdm opened this issue Mar 20, 2025 · 3 comments

Comments

@davidmdm
Copy link

TinyGo currently does not support net/http/* packages as documented here.

This is unfortunate as use-cases exist where we would want to import packages that depend on net/http/* but do not need to run networking.

For example in the Kubernetes space, we would like to write programs that depend on k8s.io/api, apimachinery and third-party operator types. Unfortunately these packages depend on net/http packages and we cannot compile them using tinygo.

Resulting in errors such as:

../../../../go/pkg/mod/golang.org/x/net@v0.37.0/internal/httpcommon/request.go:11:2: package net/http/httptrace is not in std (/Users/davidmdm/Library/Caches/tinygo/goroot-844030248698ae6eab7078512b4fefd9cf5525da9617ec2f86276fb6aa7030bc/src/net/http/httptrace)

The ask is to implement/stub/mock enough of net/http to allow tinygo to work with the kubernetes ecosystem at least at the type level.
The ask is NOT to implement networking or http.

Related issues:

@davidmdm
Copy link
Author

This would imply that the following program would compile successfully:

package main

import (
	"fmt"

	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func main() {
	fmt.Println(metav1.ObjectMeta{})
}

@b0ch3nski
Copy link

@davidmdm You can take a look at this: https://github.com/kubewarden/k8s-objects

@davidmdm
Copy link
Author

@b0ch3nski I am aware of that repo. In some cases it is good enough, but as soon as you want to depend on types found in third party operators you are back to square one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants