Sample code for 30+ languages & platforms
Go

Duplicate openssl pkey -in private.pem -pubout -out pubkey.pem

See more OpenSSL Examples

How to output the public part of a private key: Demonstrates how to duplicate this OpenSSL command:
openssl pkey -in private.pem -pubout -out pubkey.pem

Chilkat Go Downloads

Go
    success := false

    pkey := chilkat.NewPrivateKey()

    // Load the private key from an PEM file:
    success = pkey.LoadPemFile("private.pem")
    if success == false {
        fmt.Println(pkey.LastErrorText())
        pkey.DisposePrivateKey()
        return
    }

    pubKey := chilkat.NewPublicKey()
    pkey.ToPublicKey(pubKey)

    success = pubKey.SavePemFile(false,"pubKey.pem")
    if success != true {
        fmt.Println(pubKey.LastErrorText())
        pubKey.DisposePublicKey()
        pkey.DisposePrivateKey()
        pubKey.DisposePublicKey()
        return
    }

    fmt.Println("Success.")

    pkey.DisposePrivateKey()
    pubKey.DisposePublicKey()