To be clear: You sent a follow-up E-Mail to your original code, to replace
`int` with `[]byte`. That substitution is, of course, necessary to make the
code compile. So, specifically, this compiles fine:

package main

import (
    "fmt"
)

type byteview interface{string | []byte}

type ByteView[T byteview] struct {v [0]T}

func (bv ByteView[T]) Write(v T) (int, error) {
    return 0, nil
}

type Writer[T byteview] interface {
    Write(bs T)(int, error)
}

type ioWriter = Writer[[]byte]

func main() {
    fmt.Println("Hello, playground")
}

On Fri, Nov 12, 2021 at 6:21 PM Axel Wagner <axel.wagner...@googlemail.com>
wrote:

> Why not? The comment "[]byte does not satisfy comparable" seems
> irrelevant, as you don't use that constraint anywhere. It seems pretty
> well-defined, if strange and pointless, code.
>
> On Fri, Nov 12, 2021 at 6:20 PM tapi...@gmail.com <tapir....@gmail.com>
> wrote:
>
>> fine? It should not.
>>
>> On Friday, November 12, 2021 at 3:04:20 PM UTC+8
>> axel.wa...@googlemail.com wrote:
>>
>>> Please ask an actual question, don't just post some code.
>>> FTR the code you posted (with the substitution you suggest) compiles and
>>> runs fine using gotip.
>>>
>>> On Fri, Nov 12, 2021 at 6:18 AM tapi...@gmail.com <tapi...@gmail.com>
>>> wrote:
>>>
>>>> sorry, a mistake, "int" -> "[]byte".
>>>>
>>>> On Friday, November 12, 2021 at 1:08:50 PM UTC+8 tapi...@gmail.com
>>>> wrote:
>>>>
>>>>>
>>>>> package main
>>>>>
>>>>> import (
>>>>>     "fmt"
>>>>> )
>>>>>
>>>>> type byteview interface{string | int}
>>>>>
>>>>> type ByteView[T byteview] struct {v [0]T}
>>>>>
>>>>> func (bv ByteView[T]) Write(v T) (int, error) {
>>>>>     return 0, nil
>>>>> }
>>>>>
>>>>> type Writer[T byteview] interface {
>>>>>     Write(bs T)(int, error)
>>>>> }
>>>>>
>>>>> type ioWriter = Writer[[]byte] // []byte does not satisfy comparable
>>>>>
>>>>> func main() {
>>>>>     fmt.Println("Hello, playground")
>>>>> }
>>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "golang-nuts" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to golang-nuts...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/golang-nuts/5342cd82-a51f-4d9d-af79-d7a5e2a1b663n%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/golang-nuts/5342cd82-a51f-4d9d-af79-d7a5e2a1b663n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to golang-nuts+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/golang-nuts/087f84b6-7866-4e36-8bc9-a85170a26e7en%40googlegroups.com
>> <https://groups.google.com/d/msgid/golang-nuts/087f84b6-7866-4e36-8bc9-a85170a26e7en%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAEkBMfE0H%3DQVjBoypH%2B3iSoFEzt7zFhx2a24%2B4wHp5UUu5naSw%40mail.gmail.com.

Reply via email to