refactor: replace interface{} with any for modern Go style
Update callback function signatures to use the any alias introduced in Go 1.18, improving code readability and following current Go conventions. Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -34,13 +34,13 @@ type result struct {
|
|||||||
var DefaultTTS = &AliTTS{}
|
var DefaultTTS = &AliTTS{}
|
||||||
|
|
||||||
// onTaskFailed TTS 合成失败回调
|
// onTaskFailed TTS 合成失败回调
|
||||||
func (tts *AliTTS) onTaskFailed(text string, param interface{}) {
|
func (tts *AliTTS) onTaskFailed(text string, param any) {
|
||||||
p, _ := param.(*result)
|
p, _ := param.(*result)
|
||||||
p.Error = fmt.Errorf("语音合成异常: %v", text)
|
p.Error = fmt.Errorf("语音合成异常: %v", text)
|
||||||
}
|
}
|
||||||
|
|
||||||
// onSynthesisResult TTS 合成数据回调
|
// onSynthesisResult TTS 合成数据回调
|
||||||
func (tts *AliTTS) onSynthesisResult(data []byte, param interface{}) {
|
func (tts *AliTTS) onSynthesisResult(data []byte, param any) {
|
||||||
p, _ := param.(*result)
|
p, _ := param.(*result)
|
||||||
p.Data.Write(data)
|
p.Data.Write(data)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ func Play(ctx context.Context, path string, local bool) error {
|
|||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
defer close(done)
|
defer close(done)
|
||||||
|
|
||||||
_, err = eventManager.Attach(libvlc.MediaPlayerEndReached, func(libvlc.Event, interface{}) {
|
_, err = eventManager.Attach(libvlc.MediaPlayerEndReached, func(libvlc.Event, any) {
|
||||||
done <- struct{}{}
|
done <- struct{}{}
|
||||||
}, nil)
|
}, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user