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

build error: net/smtp module reports undefined: tls.Conn #4624

Open
everyx opened this issue Nov 21, 2024 · 1 comment
Open

build error: net/smtp module reports undefined: tls.Conn #4624

everyx opened this issue Nov 21, 2024 · 1 comment
Labels
network Anything to do with network use from TinyGo

Comments

@everyx
Copy link

everyx commented Nov 21, 2024

tinygo run verifier.go 
# net/smtp
/usr/lib/go/src/net/smtp/smtp.go:72:24: undefined: tls.Conn
/usr/lib/go/src/net/smtp/smtp.go:172:25: undefined: tls.Conn
verifier.go
package main

import (
	"encoding/json"
	"fmt"

	emailVerifier "github.com/AfterShip/email-verifier"
)

type Result struct {
	Data  *emailVerifier.Result `json:"data"`
	Error error                 `json:"error"`
}

func (p Result) ToJson(result Result) (*string, error) {
	bytes, err := json.Marshal(result)

	if err != nil {
		fmt.Println("Error converting to JSON:", err)
		return nil, err
	}

	json := string(bytes)

	return &json, nil
}

//export add
func verify(email string) string {
	var result Result

	verifier := emailVerifier.NewVerifier().EnableAutoUpdateDisposable()

	ret, err := verifier.Verify(email)
	if err != nil {
		result = Result{
			Data:  nil,
			Error: err,
		}
	} else {
		result = Result{
			Data:  ret,
			Error: nil,
		}
	}

	bytes, err := json.Marshal(result)
	if err != nil {
		fmt.Println("Error converting to JSON:", err)
		return fmt.Sprintf("{error:%s}", err.Error())
	}

	return string(bytes)
}

func main() {
	fmt.Println(verify("[email protected]"))
}
@deadprogram deadprogram added the network Anything to do with network use from TinyGo label Dec 14, 2024
@scottfeldman
Copy link
Contributor

This isn't working because current TinyGo TLS support is only for baremetal devices with mbed firmware for offloading the TLS protocol. TinyGo will redirect tls calls down to mbed firmware.

Seems we need someway at compile time to pick which 'net' and 'crypto/tls' packages for the target. If targeting WASM or non-baremetal, pick the standard Go packages. If targeting baremetal, pick the TinyGo 'net' and 'crypto/tls' packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
network Anything to do with network use from TinyGo
Projects
None yet
Development

No branches or pull requests

3 participants