You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's say I plan to use a go module like https://github.com/redis/go-redis in my go project and compile it with TinyGo to a specific target (I'm targeting wasip2 but I guess it can be any target). Also, let's assume that I'm not planning to use any TLS related features in go-redis.
Currently, I cannot even compile when I'm using go-redis because VersionTLS constants and VersionName(version uint16) are missing, even though I'm not planning to use them (I grabbed the following code from redis-go and added netDevImplementation):
package main
import (
"context""fmt""github.com/redis/go-redis/v9"
netDevImplementation "path/to/netdev/implementation""tinygo.org/x/drivers/netdev"
)
varctx=context.Background()
funcmain() {
netdev.UseNetdev(netDevImplementation.NewNetdev())
rdb:=redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Password: "", // no password setDB: 0, // use default DB
})
err:=rdb.Set(ctx, "key", "value", 0).Err()
iferr!=nil {
panic(err)
}
val, err:=rdb.Get(ctx, "key").Result()
iferr!=nil {
panic(err)
}
fmt.Println("key", val)
val2, err:=rdb.Get(ctx, "key2").Result()
iferr==redis.Nil {
fmt.Println("key2 does not exist")
} elseiferr!=nil {
panic(err)
} else {
fmt.Println("key2", val2)
}
// Output: key value// key2 does not exist
}
I know TLS is yet to be implemented for TinyGo, but I was wondering if we can add VersionTLS constants and VersionName(version uint16) for now so we can have modules like go-redis at least compiling.
Code to add (src/crypto/tls/common.go)
const (
VersionTLS10=0x0301VersionTLS11=0x0302VersionTLS12=0x0303VersionTLS13=0x0304// Deprecated: SSLv3 is cryptographically broken, and is no longer// supported by this package. See golang.org/issue/32716.VersionSSL30=0x0300
)
// VersionName returns the name for the provided TLS version number// (e.g. "TLS 1.3"), or a fallback representation of the value if the// version is not implemented by this package.funcVersionName(versionuint16) string {
switchversion {
caseVersionSSL30:
return"SSLv3"caseVersionTLS10:
return"TLS 1.0"caseVersionTLS11:
return"TLS 1.1"caseVersionTLS12:
return"TLS 1.2"caseVersionTLS13:
return"TLS 1.3"default:
returnfmt.Sprintf("0x%04X", version)
}
}
Problem
Let's say I plan to use a go module like https://github.com/redis/go-redis in my go project and compile it with TinyGo to a specific target (I'm targeting wasip2 but I guess it can be any target). Also, let's assume that I'm not planning to use any TLS related features in
go-redis
.Currently, I cannot even compile when I'm using
go-redis
becauseVersionTLS
constants andVersionName(version uint16)
are missing, even though I'm not planning to use them (I grabbed the following code fromredis-go
and addednetDevImplementation
):Temporarily solution?
I know TLS is yet to be implemented for TinyGo, but I was wondering if we can add
VersionTLS
constants andVersionName(version uint16)
for now so we can have modules likego-redis
at least compiling.Code to add (
src/crypto/tls/common.go
)Now it compiles and I can run it with a wasm runtime like Wasmtime.
Output as expected:
The text was updated successfully, but these errors were encountered: