From 37fd36153b2864e6fb5f3a117c98d184ccdd5cdd Mon Sep 17 00:00:00 2001 From: Luc Talatinian Date: Wed, 19 Jul 2023 16:57:35 -0400 Subject: [PATCH] prevent unused time import in event streams --- CHANGELOG_PENDING.md | 2 ++ .../model/api/codegentest/service/restjsonservice/api.go | 2 ++ private/model/api/codegentest/service/restxmlservice/api.go | 2 ++ private/model/api/codegentest/service/rpcservice/api.go | 2 ++ private/model/api/eventstream_tmpl.go | 6 ++++++ service/kinesis/api.go | 1 + service/lambda/api.go | 1 + service/lexruntimev2/api.go | 1 + service/s3/api.go | 1 + service/transcribestreamingservice/api.go | 3 +++ 10 files changed, 21 insertions(+) diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 8a1927a39ca..ea3f148310e 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -3,3 +3,5 @@ ### SDK Enhancements ### SDK Bugs +* `codegen`: Prevent unused imports from being generated for event streams. + * Potentially-unused `"time"` import was causing vet failures on generated code. diff --git a/private/model/api/codegentest/service/restjsonservice/api.go b/private/model/api/codegentest/service/restjsonservice/api.go index 4764dbb7fb5..1bc2cf6db72 100644 --- a/private/model/api/codegentest/service/restjsonservice/api.go +++ b/private/model/api/codegentest/service/restjsonservice/api.go @@ -101,6 +101,7 @@ func (c *RESTJSONService) EmptyStreamWithContext(ctx aws.Context, input *EmptySt } var _ awserr.Error +var _ time.Time // EmptyStreamEventStream provides the event stream handling for the EmptyStream. // @@ -326,6 +327,7 @@ func (c *RESTJSONService) GetEventStreamWithContext(ctx aws.Context, input *GetE } var _ awserr.Error +var _ time.Time // GetEventStreamEventStream provides the event stream handling for the GetEventStream. // diff --git a/private/model/api/codegentest/service/restxmlservice/api.go b/private/model/api/codegentest/service/restxmlservice/api.go index 7bf926fdbea..cd19abfa4c4 100644 --- a/private/model/api/codegentest/service/restxmlservice/api.go +++ b/private/model/api/codegentest/service/restxmlservice/api.go @@ -101,6 +101,7 @@ func (c *RESTXMLService) EmptyStreamWithContext(ctx aws.Context, input *EmptyStr } var _ awserr.Error +var _ time.Time // EmptyStreamEventStream provides the event stream handling for the EmptyStream. // @@ -326,6 +327,7 @@ func (c *RESTXMLService) GetEventStreamWithContext(ctx aws.Context, input *GetEv } var _ awserr.Error +var _ time.Time // GetEventStreamEventStream provides the event stream handling for the GetEventStream. // diff --git a/private/model/api/codegentest/service/rpcservice/api.go b/private/model/api/codegentest/service/rpcservice/api.go index a7eacfdf2ee..8a48b9c15fc 100644 --- a/private/model/api/codegentest/service/rpcservice/api.go +++ b/private/model/api/codegentest/service/rpcservice/api.go @@ -103,6 +103,7 @@ func (c *RPCService) EmptyStreamWithContext(ctx aws.Context, input *EmptyStreamI } var _ awserr.Error +var _ time.Time // EmptyStreamEventStream provides the event stream handling for the EmptyStream. // @@ -371,6 +372,7 @@ func (c *RPCService) GetEventStreamWithContext(ctx aws.Context, input *GetEventS } var _ awserr.Error +var _ time.Time // GetEventStreamEventStream provides the event stream handling for the GetEventStream. // diff --git a/private/model/api/eventstream_tmpl.go b/private/model/api/eventstream_tmpl.go index 64846cfaaa8..fe3c19c4857 100644 --- a/private/model/api/eventstream_tmpl.go +++ b/private/model/api/eventstream_tmpl.go @@ -22,8 +22,14 @@ func renderEventStreamAPI(w io.Writer, op *Operation) error { op.API.AddSDKImport("private/protocol/eventstream") op.API.AddSDKImport("private/protocol/eventstream/eventstreamapi") + // usages of these imports are conditional - generate a compile-only + // reference to avoid potential unused imports: + // - awserr is only used for input streams or json protocols + // - time is only used for input streams or if an event payload has a + // timestamp field w.Write([]byte(` var _ awserr.Error +var _ time.Time `)) return eventStreamAPITmpl.Execute(w, op) diff --git a/service/kinesis/api.go b/service/kinesis/api.go index 7bf240e0d41..39722733c8b 100644 --- a/service/kinesis/api.go +++ b/service/kinesis/api.go @@ -3427,6 +3427,7 @@ func (c *Kinesis) SubscribeToShardWithContext(ctx aws.Context, input *SubscribeT } var _ awserr.Error +var _ time.Time // SubscribeToShardEventStream provides the event stream handling for the SubscribeToShard. // diff --git a/service/lambda/api.go b/service/lambda/api.go index 9d4a863596a..d31909be887 100644 --- a/service/lambda/api.go +++ b/service/lambda/api.go @@ -3737,6 +3737,7 @@ func (c *Lambda) InvokeWithResponseStreamWithContext(ctx aws.Context, input *Inv } var _ awserr.Error +var _ time.Time // InvokeWithResponseStreamEventStream provides the event stream handling for the InvokeWithResponseStream. // diff --git a/service/lexruntimev2/api.go b/service/lexruntimev2/api.go index ade172cfcec..72b568a5871 100644 --- a/service/lexruntimev2/api.go +++ b/service/lexruntimev2/api.go @@ -723,6 +723,7 @@ func (c *LexRuntimeV2) StartConversationWithContext(ctx aws.Context, input *Star } var _ awserr.Error +var _ time.Time // StartConversationEventStream provides the event stream handling for the StartConversation. // diff --git a/service/s3/api.go b/service/s3/api.go index 08ef909ba8c..2882d45568f 100644 --- a/service/s3/api.go +++ b/service/s3/api.go @@ -10709,6 +10709,7 @@ func (c *S3) SelectObjectContentWithContext(ctx aws.Context, input *SelectObject } var _ awserr.Error +var _ time.Time // SelectObjectContentEventStream provides the event stream handling for the SelectObjectContent. // diff --git a/service/transcribestreamingservice/api.go b/service/transcribestreamingservice/api.go index 2b00a2285d8..c442b266104 100644 --- a/service/transcribestreamingservice/api.go +++ b/service/transcribestreamingservice/api.go @@ -165,6 +165,7 @@ func (c *TranscribeStreamingService) StartCallAnalyticsStreamTranscriptionWithCo } var _ awserr.Error +var _ time.Time // StartCallAnalyticsStreamTranscriptionEventStream provides the event stream handling for the StartCallAnalyticsStreamTranscription. // @@ -557,6 +558,7 @@ func (c *TranscribeStreamingService) StartMedicalStreamTranscriptionWithContext( } var _ awserr.Error +var _ time.Time // StartMedicalStreamTranscriptionEventStream provides the event stream handling for the StartMedicalStreamTranscription. // @@ -947,6 +949,7 @@ func (c *TranscribeStreamingService) StartStreamTranscriptionWithContext(ctx aws } var _ awserr.Error +var _ time.Time // StartStreamTranscriptionEventStream provides the event stream handling for the StartStreamTranscription. //